Custom race listener

Topics: Logging Application Block
Dec 31, 2008 at 4:22 AM

Hi,

I'm attempting to write a custome trace listener for Ent Lib 4.1, I have followed all the steps suggested but when I attempt to load up the assembly where the extension was defined i get the message:

unable to load references for the specified assembly, please ensure all references are in the same directory as the assembly which is loaded.

Can anyone suggest a way to get a specific message.

 

Dec 31, 2008 at 8:24 AM
You might be encountering this issue.
http://www.codeplex.com/entlib/WorkItem/View.aspx?WorkItemId=20410

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 1, 2009 at 11:56 PM
I have attempted to manually add the reference:

AA.Orders..Factory.Core.Logging.XPOLogging, AA.Orders..Factory.Core.Logging, Version=1.0.0.27118, Culture=neutral, PublicKeyToken=null

but get an error as in the following (below), I belive this is because I am specifying the wrong version, i.e. 1.0.0.27118, which is the version of the assembly (dll) that this class was built in. Is this becauise of the version?

Microsoft.Practices.ObjectBuilder2.BuildFailedException was unhandled by user code
Message="The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, null]) failed: The type 'AA.Orders.ServerSide.Factory.Core.Logging.XPOLogging, AA.Orders.ServerSide.Factory.Core.Logging, Version=1.0.0.27118, Culture=neutral, PublicKeyToken=null' cannot be resolved. Please verify the spelling is correct or that the full type name is provided. (Strategy type ConfiguredObjectStrategy, index 2)"
Source="Microsoft.Practices.ObjectBuilder2"
BuildKey="Build Key[Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, null]"
ExecutingStrategyIndex=2
ExecutingStrategyTypeName="ConfiguredObjectStrategy"
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.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterFactory.Create()
at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.get_Writer()
at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.ShouldLog(LogEntry log)
at AA.Orders.ServerSide.Factory.Core.Logging.PegasusLogger.LogEntry(String LogMessage, String Category, TraceEventType EventType, Dictionary`2 dictionary) in C:\RMSSV2\RMSS Codename Pegasus\ServerObjects\Factory\Core\Logging\PegasusLogger.cs:line 71
at AA.Orders.ServerSide.Factory.Core.SavedSearch.SavedSearchFactory.SaveNewSearch(CallingClientInfo ClientInfo, SavedSearchDTO NewSearchDTO) in C:\RMSSV2\RMSS Codename Pegasus\ServerObjects\Factory\Core\SavedSearch\SavedSearchFactory.cs:line 89
at AA.Orders.Services.Services.SavedSearchService.SaveSearch(CallingClientInfo ClientInfo, SavedSearchDTO SavedSearch) in C:\RMSSV2\RMSS Codename Pegasus\Services\Services\SavedSearchService.cs:line 37
at SyncInvokeSaveSearch(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
InnerException: System.ArgumentException
Message="The type 'AA.Orders.ServerSide.Factory.Core.Logging.XPOLogging, AA.Orders.ServerSide.Factory.Core.Logging, Version=1.0.0.27118, Culture=neutral, PublicKeyToken=null' cannot be resolved. Please verify the spelling is correct or that the full type name is provided."
Source="Microsoft.Practices.EnterpriseLibrary.Common"
StackTrace:
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.NameTypeConfigurationElement.get_Type()
at Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.SystemDiagnosticsTraceListenerAssembler.Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerAssembler.Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedObjectFactory`2.Create(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.TraceListenerCustomFactory.Create(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedCustomFactory`2.Create(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.TraceListenerCustomFactory.Create(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache, TraceListenerCache traceListenersCache)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogSourceCustomFactory.Create(IBuilderContext context, TraceSourceData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache, TraceListenerCache traceListenersCache)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolderCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
InnerException:
Jan 2, 2009 at 4:31 AM
No I don't think it's caused by the version since you said it's the version of the assembly where the class is in.  (Anyway, just double check the assembly info of the project).  But I need more info here, what piece of code causes this error?

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 2, 2009 at 6:09 AM
Hi,

 my code is standard stuff, as below, and the exception occurs on the line Logger.ShouldLog

if (Logger.ShouldLog(logEntry))

LogEntry

 

logEntry = new LogEntry();

 

logEntry.Categories.Add(Category);

logEntry.Message = LogMessage;

logEntry.Severity = EventType;

 

if (Logger.ShouldLog(logEntry))


Many Thanks in advance

 

Jan 2, 2009 at 9:56 AM
Are you sure you were able to reference the assembly? Could you check the bin folder of the project if the dll gets copied in it? Or you can send me your solution so I can have a look.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 5, 2009 at 1:45 AM
Following are the fundamental aspects of EL. If they are good, then you should be able to resolve easily.
  1. Ensure that strong named assemblies are properly recognized with in and across configs.
  2. Use Enterprise Configuration Library Tool to modify the config file
  3. Ensure that distributed keys of Ent Libs are matching.
Jan 5, 2009 at 2:43 AM
Hi,

thanks everyone for the help, of which I have tried, but to no avail. I am now going with version 4.0, as there is simply not enoygh time, we need this logging module finished today.

It is strange however that the exact same code works with 4.0 and not 4.1 tho.

Thanks

Again.