I have a Solution which contains a Web project and a Class Library project. The Class library project contains Enterprise library 5.0 and app.config. When I try to perform a Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write, I get the following
exception:
Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type LogWriter 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.LogWriter,(none)
If I move all the class files to the web project and have the Enterprise library configuration in the Web.config, everything works fine. I guess the issue is that the Enterprise library is not detecting the app.config which contains all the configuration.
How can I have my enterprise library use the App.config present in its prroject.
Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type LogWriter 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.LogWriter,(none)
I read
the configuration file
using the
following code:
Dim container As New UnityContainer
Dim configurator = New UnityContainerConfigurator(container)
' Read the configuration files and set up the container.
EnterpriseLibraryContainer.ConfigureContainer(configurator, New FileConfigurationSource("file.config"))
_LogWriter = container.Resolve(Of LogWriter)()
' add custom listener to logWriter
If IsLogging Then
Dim collList As New List(Of TraceListener)
Dim dbTraceList As TraceListener = Nothing
Dim dblogSource As LogSource = Nothing
dbTraceList = New SIALogListener(_connLog, _databaseLog)
collList.Add(dbTraceList)
dblogSource = New LogSource("CustomDBLog", collList, SourceLevels.All)
dblogSource.AutoFlush = True
_LogWriter.TraceSources("General").Listeners.Add(dbTraceList)
End If
toavoid connectingto the
apporweb.configfile
The
library
worksperfectly. NETbut
loading it
fromVB6COM
interop
modeis evidentin
theerrorthat
I write.
Can you
helporsuggest
possible
solutions? What
seemsstrangeto
meis thatthe
dllin aVS2010
function
perfectly
andhighlightsthe
problem
onlyin theVB6
Frenz
Member
15 Points
41 Posts
Having Enterprise Library 5.0 use app.config
Nov 19, 2010 04:04 AM|LINK
Hi,
I have a Solution which contains a Web project and a Class Library project. The Class library project contains Enterprise library 5.0 and app.config. When I try to perform a Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write, I get the following exception:
Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type LogWriter 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.LogWriter,(none)
If I move all the class files to the web project and have the Enterprise library configuration in the Web.config, everything works fine. I guess the issue is that the Enterprise library is not detecting the app.config which contains all the configuration. How can I have my enterprise library use the App.config present in its prroject.
Kindly help me with this regard.
Thanks in advance.
DarrellNorto...
All-Star
86795 Points
9644 Posts
Moderator
MVP
Re: Having Enterprise Library 5.0 use app.config
Nov 19, 2010 09:43 AM|LINK
You need to add a few settings in the web.config to point to an external (non web.config) config file:
http://www.pnpguidance.net/Post/EnterpriseLibraryExternalConfigurationSourceApplicationBlockSettings.aspx
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
dionisifam
Member
2 Points
1 Post
Re: Having Enterprise Library 5.0 use app.config
Jan 04, 2011 08:36 AM|LINK
hi,
I have the same problem experienced by Frenz:
Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type LogWriter 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.LogWriter,(none)
I read the configuration file using the following code:
Dim container As New UnityContainer
Dim configurator = New UnityContainerConfigurator(container)
' Read the configuration files and set up the container.
EnterpriseLibraryContainer.ConfigureContainer(configurator, New FileConfigurationSource("file.config"))
_LogWriter = container.Resolve(Of LogWriter)()
' add custom listener to logWriter
If IsLogging Then
Dim collList As New List(Of TraceListener)
Dim dbTraceList As TraceListener = Nothing
Dim dblogSource As LogSource = Nothing
dbTraceList = New SIALogListener(_connLog, _databaseLog)
collList.Add(dbTraceList)
dblogSource = New LogSource("CustomDBLog", collList, SourceLevels.All)
dblogSource.AutoFlush = True
_LogWriter.TraceSources("General").Listeners.Add(dbTraceList)
End If
to avoid connecting to the app or web.config file
The library works perfectly. NET but loading it from VB6 COM interop mode is evident in the error that I write.
Can you help or suggest possible solutions?
What seems strange to me is that the dll in a VS2010 function perfectly and highlights the problem only in the VB6
Thanks
Regards