Ploblem running Microsoft Enterprise Library 2.0 Solution

Topics: Exception Handling Application Block, Logging Application Block
Dec 14, 2011 at 5:12 PM

Hi everybody, I'm new with Microsoft Enterprise Library and I'm getting problems when I try to work with an existing Solution developed with version 2 of microsoft framework.

My escenario is the next:

I was given de complete solution in order to fix some issues but when I run it I get errors like the one at the of my post. 

I'm not working in the machine that was used to develop the application so my development enviroment is a new one.

So, could you please help me telling me all the steps I need to do in order to make this application run and avoid this kind of errors?

Do I need to install the enterprise library and set new references to de Enterprise Library Dlls? Or can I work with the same included in the solution?

Or what can I do in order to resolve this kind of problems?

Hope you can help and thanks in advance!

System.Configuration.ConfigurationErrorsException: The type Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null from configuration could not be created. (C:\Users\Administrador\Documents\No\Codigo\revisar\ProvisioningWebSite\Provisioning\web.config line 65)   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)   at System.Web.HttpContext.GetSection(String sectionName)   at System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName)   at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)   at System.Configuration.ConfigurationManager.GetSection(String sectionName)   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSourceImplementation.GetSection(String sectionName)   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource.GetSection(String sectionName)   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings.GetExceptionHandlingSettings(IConfigurationSource configurationSource)   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingConfigurationView.get_ExceptionHandlingSettings()   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingConfigurationView.GetExceptionPolicyData(String policyName)   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.GetConfiguration(String id, IConfigurationSource configurationSource)   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)   at Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)   at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)   at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp[TTypeToBuild](IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies)   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, String id, IConfigurationSource configurationSource)   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase`1.Create(String name)   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName)   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)   at provisioning.ActivateService(String strCOID, String strPTN) in c:\Users\Administrador\Documents\No\Codigo\revisar\ProvisioningWebSite\Provisioning\App_Code\provisioning.cs:line 206

----------------------------------------------------

line 206 is:

ExceptionPolicy.HandleException(ex, "MPSPolicy");

---------------------------------------------------

And part of my configuration file is:

<configSections>
		<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
		<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
		<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
	</configSections>
<exceptionHandling>
		<exceptionPolicies>
			<add name="MPSPolicy">
				<exceptionTypes>
					<add type="System.ArgumentException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="ArgumentException">
						<exceptionHandlers>
							<add logCategory="Provisioning_InvalidArguments" eventId="100003" severity="Error" title="Argumentos err�neos en el sistema de provisionamiento" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" priority="0" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Logging Handler"/>
						</exceptionHandlers>
					</add>
	         		</exceptionTypes>
			</add>
		</exceptionPolicies>
	</exceptionHandling>

Dec 15, 2011 at 4:41 AM

You should verify that the Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll is deployed.

Because it is not referenced directly in code but through configuration Visual Studio won't copy it to the output directory. 
You can add a reference to Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll to your project
or create a post build command to copy the file to the output directory. 

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com