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
Member
5 Points
40 Posts
Having Enterprise Library 5.0 use app.config
Nov 19, 2010 12:04 AM|Frenz|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.
All-Star
43204 Points
10243 Posts
MVP
Re: Having Enterprise Library 5.0 use app.config
Nov 19, 2010 05:43 AM|DarrellNorton|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.
None
0 Points
1 Post
Re: Having Enterprise Library 5.0 use app.config
Jan 04, 2011 04:36 AM|dionisifam|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