A co-worker encountered the following exception when trying to use a library that uses the Microsoft Enterprise Library:
System.Reflection.TargetInvocationException was unhandled by user code
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ExplicitInstrumentationAttacher.BindInstrumentation()
...
This is caused when using the built-in instrumentation features of the Enterprise Library by enabling instrumentation in the configuration file before installing the instrumentation.
There are at least two possible solutions:
1. Disable instrumentation
One possible solution is to disable the usage of instrumentation. This can be done by adding the following lines to the configuration file:
<configuration>
<configSections>
<section name="instrumentationConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.Configuration.InstrumentationConfigurationSection, Microsoft.Practices.EnterpriseLibrary.Common"/>
</configSections>
<instrumentationConfiguration performanceCountersEnabled="false" />
</configuration>
2. Install services for the application blocks
Another solution would be to install the services for the Enterprise Library application blocks instrumentation by running the batch file that you will find in Start -> All Programs -> Microsoft pattern & practices -> Enterprise Libary - January 2006 -> Install Instrumentation
Cross-posted from
The .NET Aficionado