Exception when web-hosted

Oct 20, 2008 at 5:21 PM
Experts,

I am using Unity in WCF with a custom IInstanceProvider (similar to the one found in Unity Contrib).
When running in a self-host environment (like Console or Windows Service) everything works fine - but when I web/WAS-host my WCF service I get an exception on
   container.GetInstance(type);

This is the exception:

Microsoft.Practices.ServiceLocation.ActivationException was unhandled by user code
  Message="Activation error occured while trying to get instance of type MediaService, key \"\""
  Source="Microsoft.Practices.ServiceLocation"
  StackTrace:
       at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 53
       at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 34
       at Thinktecture.ServiceModel.IoC.IocInstanceProvider.GetInstance(InstanceContext instanceContext, Message message) in C:\TecTeacher\Libs\Thinktecture.ServiceModel\IoC\IocInstanceProvider.cs:line 71
       at System.ServiceModel.Dispatcher.InstanceBehavior.GetInstance(InstanceContext instanceContext, Message request)
       at System.ServiceModel.InstanceContext.GetServiceInstance(Message message)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
  InnerException: Microsoft.Practices.Unity.ResolutionFailedException
       Message="Resolution of the dependency failed, type = \"MediaService\", name = \"\". Exception message is: The current build operation (build key Build Key[Thinktecture.TecTeacher.MediaServices.MediaService, null]) failed: The parameter logic could not be resolved when attempting to call constructor Thinktecture.TecTeacher.MediaServices.MediaService(Thinktecture.TecTeacher.MediaLogicInterfaces.IMediaLogic logic). (Strategy type Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy, index 2)"
       Source="Microsoft.Practices.Unity"
       StackTrace:
            at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
            at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name)
            at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name)
            at Microsoft.Practices.Unity.ServiceLocatorAdapter.UnityServiceLocator.DoGetInstance(Type serviceType, String key) in C:\Users\Chief Christian\Desktop\CommonServiceLocator.UnityAdapter\UnityAdapter\UnityServiceLocator.cs:line 27
            at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 49
       InnerException: Microsoft.Practices.ObjectBuilder2.BuildFailedException
            Message="The current build operation (build key Build Key[Thinktecture.TecTeacher.MediaServices.MediaService, null]) failed: The parameter logic could not be resolved when attempting to call constructor Thinktecture.TecTeacher.MediaServices.MediaService(Thinktecture.TecTeacher.MediaLogicInterfaces.IMediaLogic logic). (Strategy type Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy, index 2)"
            Source="Microsoft.Practices.ObjectBuilder2"
            ExecutingStrategyIndex=2
            StackTrace:
                 at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
                 at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
            InnerException: System.InvalidOperationException
                 Message="The parameter logic could not be resolved when attempting to call constructor Thinktecture.TecTeacher.MediaServices.MediaService(Thinktecture.TecTeacher.MediaLogicInterfaces.IMediaLogic logic)."
                 Source="Microsoft.Practices.ObjectBuilder2"
                 StackTrace:
                      at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForResolutionFailed(Exception inner, String parameterName, String constructorSignature, IBuilderContext context)
                      at BuildUp_Thinktecture.TecTeacher.MediaServices.MediaService(IBuilderContext )
                      at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
                      at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
                      at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                 InnerException: Microsoft.Practices.ObjectBuilder2.BuildFailedException
                      Message="The current build operation (build key Build Key[Thinktecture.TecTeacher.MediaBusinessLogic.MediaManager, null]) failed: Value cannot be null.\r\nParameter name: type (Strategy type Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy, index 2)"
                      Source="Microsoft.Practices.ObjectBuilder2"
                      ExecutingStrategyIndex=2
                      StackTrace:
                           at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                           at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
                           at BuildUp_Thinktecture.TecTeacher.MediaServices.MediaService(IBuilderContext )
                      InnerException: System.ArgumentNullException
                           Message="Value cannot be null.\r\nParameter name: type"
                           Source="mscorlib"
                           ParamName="type"
                           StackTrace:
                                at System.Activator.CreateInstance(Type type, Boolean nonPublic)
                                at System.Activator.CreateInstance(Type type)
                                at Thinktecture.TecTeacher.DataAccess.DataAccessFactory.CreateInstance() in C:\TecTeacher\MediaServices\DataAccess\DataAccessFactory.cs:line 41
                                at Thinktecture.TecTeacher.MediaBusinessLogic.MediaManager..ctor() in C:\TecTeacher\MediaServices\MediaBusinessLogic\MediaManager.cs:line 35
                                at BuildUp_Thinktecture.TecTeacher.MediaBusinessLogic.MediaManager(IBuilderContext )
                                at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
                                at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
                                at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                           InnerException:


Any idea what could be the problem?

Thanks.

Oct 20, 2008 at 7:06 PM
It doesn't seem to be a permission problem: I ran the application pool with my privileges and it still did not work.
Any other idea?

Thanks.
Oct 20, 2008 at 7:08 PM
Looks like the container isn't configured as you expect, but without the initialization code it's hard to be sure. Are you using a config file or API, and if a config file, did you move the config information to the right spot.

Reading the stack trace, it's trying to build an instance of MediaService. The constructor parameter "logic" is failing to resolve

It looks like logic ends up being mapped to MediaManager. The actual buildup is failing inside the constructor to MediaManager - it's calling DataAccess.Factory.CreateInstance, which then calls ActivatorCreateInstance, but it's passing null to CreateInstance.

So what's going on inside MediaManager that it's passing null?
Oct 20, 2008 at 8:01 PM
Doh - that was a good hint...
Sometime it is of real value to read the stack trace ;)

Thanks Chris.

Oct 20, 2008 at 9:00 PM
Does that mean you fixed it? What was it?

-Chris

Oct 20, 2008 at 9:35 PM
1. needed assemblies (for data access) were not in place. This is surely one of the primary problems of dependency injection ;)
2. part of my data access layer uses Linq2Sql - but not in the way VS 2008 does, but rather by using a .map file. And this file could not be found.

Thx again Chris.
Mar 18, 2010 at 9:12 PM
<!-- html, body { font-family:tahoma, sans-serif; font-size:90%; } A:link {text-decoration: underline; color=#8B008B;} A:visited {text-decoration: underline; color=#DB00DB} --><!-- .hoverLinkEmuLink { text-decoration: underline; cursor: pointer; } .normalLinkEmuLink { } -->

I got same error when i try to write log entry in console application using EntLib 5.0 Beta 2:

var log = new LogEntry()
                          {
                              ActivityId = _newActivityId,
                              Message = message,
                              Severity = TraceEventType.Start
                          };

Logger.Write(log);

Logger invoked in interception of method invokation by TransparentProxyInterceptor (I tried to trace executing time of methods marked by attribute).

Error:

Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type LogWriter, key "" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type TraceListener cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:

Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter.__default__ (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, (none))
Resolving parameter "structureHolder" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder structureHolderMicrosoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProviderMicrosoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator updateCoordinator)
Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder.__default__ (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder, (none))
Resolving parameter "traceSources" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable`1[[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] filters, System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceSourceNames, System.Collections.Generic.IEnumerable`1[[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] traceSources, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource allEventsTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource notProcessedTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource errorsTraceSource, System.String defaultCategory, System.Boolean tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch, System.Boolean revertImpersonation)
Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,General
Resolving parameter "traceListeners" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String name, System.Collections.Generic.IEnumerable`1[[System.Diagnostics.TraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceListeners, System.Diagnostics.SourceLevels level, System.Boolean autoFlush, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider)
Resolving System.Diagnostics.TraceListener,Event Log Listener
---> System.InvalidOperationException: The type TraceListener cannot be constructed. You must configure the container to supply this value.
в Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext contextSelectedConstructor selectedConstructor) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\Creation\DynamicMethodConstructorStrategy.cs: line 289
в Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\Creation\DynamicMethodConstructorStrategy.cs: line 71
в Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs: line 110
в Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext contextNamedTypeBuildKey buildKey) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\DynamicMethodBuildPlanCreatorPolicy.cs: line 48
в Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\BuildPlanStrategy.cs: line 37
в Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs: line 110
в Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\BuilderContext.cs: line 220
в Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\NamedTypeDependencyResolverPolicy.cs: line 51
в Microsoft.Practices.Unity.ResolvedArrayWithElementsResolverPolicy.DoResolve(IBuilderContext contextIDependencyResolverPolicy[] elementPolicies) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\ResolvedArrayWithElementsResolverPolicy.cs: line 73
в Microsoft.Practices.Unity.ResolvedArrayWithElementsResolverPolicy.Resolve(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\ResolvedArrayWithElementsResolverPolicy.cs: line 64
в BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(IBuilderContext)
в Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\DynamicMethodBuildPlan.cs: line 37
в Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\BuildPlanStrategy.cs: line 43
в Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs: line 110
в Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\BuilderContext.cs: line 220
в Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\NamedTypeDependencyResolverPolicy.cs: line 51
в Microsoft.Practices.Unity.ResolvedArrayWithElementsResolverPolicy.DoResolve(IBuilderContext contextIDependencyResolverPolicy[] elementPolicies) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\ResolvedArrayWithElementsResolverPolicy.cs: line 73
в Microsoft.Practices.Unity.ResolvedArrayWithElementsResolverPolicy.Resolve(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\ResolvedArrayWithElementsResolverPolicy.cs: line 64
в BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(IBuilderContext)
в Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\DynamicMethodBuildPlan.cs: line 37
в Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\BuildPlanStrategy.cs: line 43
в Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs: line 110
в Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\BuilderContext.cs: line 220
в Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\NamedTypeDependencyResolverPolicy.cs: line 51
в BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(IBuilderContext)
в Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\DynamicMethodBuildPlan.cs: line 37
в Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\BuildPlanStrategy.cs: line 43
в Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs: line 110
в Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type tObject existingString nameIEnumerable`1 resolverOverrides) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs: line 511
--- Конец трассировки внутреннего стека исключений ---
в Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type tObject existingString nameIEnumerable`1 resolverOverrides) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs: line 515
в Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type tString nameIEnumerable`1 resolverOverrides) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs: line 485
в Microsoft.Practices.Unity.UnityContainer.Resolve(Type tString nameResolverOverride[] resolverOverrides) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs: line 173
в Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceTypeString key) в e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityServiceLocator.cs: line 64
в Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceTypeString key) в c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs: line 49
--- Конец трассировки внутреннего стека исключений ---
в Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceTypeString key) в c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs: line 53
в Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance<TService>() в c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs: line 90
в Microsoft.Practices.EnterpriseLibrary.Logging.Logger.get_Writer() в Logger.cs: line 402

 

App.Config:

 

 

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" requirePermission="true"/>
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" requirePermission="true"/>
    </configSections>
    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
        <listeners>
            <add name="Database Trace Listener" 
				 type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database" 
				 listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database" 
				 databaseInstanceName="LocalSqlServer" 
				 writeLogStoredProcName="WriteLog" 
				 addCategoryStoredProcName="AddCategory" 
				 formatter="Text Formatter" 
				 traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId"/>
        </listeners>
        <formatters>
            <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging" template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter"/>
        </formatters>
        <categorySources>
            <add switchValue="All" name="General">
                <listeners>
                    <add name="Event Log Listener"/>
                </listeners>
            </add>
        </categorySources>
        <specialSources>
            <allEvents switchValue="All" name="All Events"/>
            <notProcessed switchValue="All" name="Unprocessed Category"/>
            <errors switchValue="All" name="Logging Errors &amp; Warnings">
                <listeners>
                    <add name="Event Log Listener"/>
                </listeners>
            </errors>
        </specialSources>
    </loggingConfiguration>
    <dataConfiguration defaultDatabase="LocalSqlServer"/>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

 

 

Mar 19, 2010 at 7:58 AM

This is an issue with Entlib, not the container. Or more specifically, your configuration. The logging block is configured incorrectly. You've added a database trace listener, but the only listener you've added to the the General category is "Event Log Listener" which is not defined.

Just open up your config file in the config tool, and it should give you a validation error about an unknown listener pretty quickly. If it doesn't, let me know.

 

Mar 19, 2010 at 11:42 AM
Edited Mar 19, 2010 at 12:21 PM

Config tool generate this lines:

 

<configSections>
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=null" requirePermission="true" />
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.315.0, Culture=neutral, PublicKeyToken=null" requirePermission="true" />
    </configSections>

 

After start it application show exception what Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=null could not be loaded (0x80131040).

This library already included in project references.

And can i start config tool with some parameter which including app.config file path to launch it with already opened file?

Apr 14, 2010 at 4:29 AM

Modify your XML

<categorySources>
            <add switchValue="All" name="General">
                <listeners>
                    <add name="Database Trace Listener"/>
                </listeners>
            </add>
        </categorySources>
        <specialSources>
            <allEvents switchValue="All" name="All Events"/>
            <notProcessed switchValue="All" name="Unprocessed Category"/>
            <errors switchValue="All" name="Logging Errors &amp; Warnings">
                <listeners>
                    <add name="Database Trace Listener"/>
                </listeners>
            </errors>
        </specialSources>

Apr 14, 2010 at 11:29 AM

Already fixed. Thank you.

Oct 19, 2010 at 3:26 PM

I am having the same problem ..

Can any body help  me its saying Activation Error Occured.. in my enterprise logging

 

Thanks