An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in Microsoft.Practices.EnterpriseLibrary.Data.dll

Topics: Building and extending application blocks, Data Access Application Block, Enterprise Library Core
Feb 17, 2009 at 1:31 PM
Hi

I get the following message when I run a windows service :

An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in Microsoft.Practices.EnterpriseLibrary.Data.dll

Additional information: An error occurred creating the configuration section handler for dataConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b45f42118d296492' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

i use enterprise library version 2.0 ( jan2006 ) in a windows service app.  Ive added a reference to the application that points to the above assembly and also have a app config that has an entry :

 

<

section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b45f42118d296492" />


when i install the windows app and try and run it, i get the above message.

any help would be very much appreciated

thanks
Paris Baughman

 

Feb 18, 2009 at 1:50 AM
Do you have any other versions of entlib installed?  If you open your configuration using the configuration tool, were all of the blocks properly loaded?



Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Feb 18, 2009 at 9:10 AM

Thanks for your reply. 

Do you have any other versions of entlib installed? - Yes i do, 3.1.  should i remove it ?

If you open your configuration using the configuration tool, were all of the blocks properly loaded?

How do i do this ?  When i run the enterprise lib configuration tool nothing appears in the main area.  And when i try and open application,  there is only a test.exe that appears

Sorry, Im very new to the enterprise library  and ive just been asked to look at a problem in a windows service which i know nothing about...

Thanks

Paris

Feb 18, 2009 at 9:11 AM

Thanks for your reply. 

Do you have any other versions of entlib installed? - Yes i do, 3.1.  should i remove it ?

If you open your configuration using the configuration tool, were all of the blocks properly loaded?

How do i do this ?  When i run the enterprise lib configuration tool nothing appears in the main area.  And when i try and open application,  there is only a test.exe that appears

Sorry, Im very new to the enterprise library  and ive just been asked to look at a problem in a windows service which i know nothing about...

Thanks

Paris

Feb 18, 2009 at 9:15 AM
Don't uninstall yet, check first if you have entlib assemblies in GAC, remove if there are any. 

You can open your configuration file in the entlib configuration tool by right clicking on the config file, select open with, browse for EntLibConfig.exe which can be found in the installation folder of entlib usually in Program Files -> Microsot Enterprise Library (version) -> bin folder.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Feb 18, 2009 at 9:27 AM
there doesnt to be any entlib assemblies in GAC ( c:\windows\assembly )

Entlibconfig.exe seems to be empty.  i went exactly where you want me to go.  there is a file called entlibconfig.  i double-clicked it
and there was nothing in the main areas, the left hand column and main sections where empty..
Feb 18, 2009 at 9:39 AM
Is there a DAAB section in the config tool?  I suggest you create your config using the tool, it's easier actually.  Are you familiar on how to use it?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Feb 18, 2009 at 9:44 AM
Ive checked and there is no DAAB section.  Sorry Sarah, Im not familiar, would it be possible if you can
go through it with me ?

thanks
Feb 18, 2009 at 10:19 AM

Sure, anyway, I think you'll get the hang of it easily.   After opening your config file in the configuration tool, you'll see a node representing your configuration file.  just right click on it and select New -> then your desired application block.  It's pretty much straight forward.  Just right click on the nodes on which you want to add an entry.  For example, if you choose to add the Data Access Application Block, you'll then see a Connection Strings node under it.  So if you wish to add a new connection string, just right click on it, select New, then click on Connection string.  Hope this helps.

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

Feb 18, 2009 at 10:47 AM
i did what you asked, saved it.

then i tried my windows service again and i still get the same error message

is there anything i should do ?
Feb 18, 2009 at 11:07 AM
Does it complain about the same dll? Still the Data assembly?  If you have other entlib sections in your configuration file, create them in the tool as well.  Make sure you referenced the correct dll.  The 2.0 version from the installation folder (Program Files -> Microsoft Enterprise Library -> bin).  If this still doesn't work, try uninstalling the other entlib version.



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

Feb 18, 2009 at 11:37 AM
it does complain about the same assembly.  I have created a further 2, instrumentation and logging in the entlib config.
i checked the the dll in the bin folder of my windows service app and is connected to the C:\Program Files\Microsoft Enterprise Library January 2006\bin\Microsoft.Practices.EnterpriseLibrary.Data.dll

i have just removed the 3.1 version of entlib.

sorry to say, it still comes up with the same message...

is there anything else i can try ?
Feb 18, 2009 at 12:00 PM
See this thread - http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=41127


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

Feb 18, 2009 at 12:29 PM
looked at the link and checked my machine config at this location C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
unfortunatley, there were no entries... i so was hoping that it would be something like that....

anything else i can try ?

Feb 18, 2009 at 12:36 PM

Hmmm, this is weird.  Aren't there are any entlib blocks in your config that doesn't get loaded properly in the configuration tool?  Check out also this blog and see if we missed anything.
http://blogs.msdn.com/tomholl/archive/2007/04/19/avoiding-configuration-pitfalls-with-incompatible-copies-of-enterprise-library.aspx

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

Feb 18, 2009 at 2:10 PM
ok, had a look at the blog, the only thing i can see being a problem the following :

Note that the Start Menu shortcut that installs with Enterprise Library 3.0 points to the copy in "C:\Program Files\Microsoft Enteprise Library 3.0 - April 2007\bin" which uses the strong-named assemblies. If you want to use the non-strong-named one, you'll need to navigate to the "C:\EntLib3Src\App Blocks\bin" folder yourself (or update the Start Menu shortcut).

ive been looking at the first copy ("C:\Program Files\Microsoft Enteprise Library 3.0 - April 2007\bin") which looks at the strong names ones.  i presume the strong name ones should be in the GAC, which does not hold any enterprise stuff.  so, where is the other version for enterprise library 2 ( "C:\EntLib3Src\App Blocks\bin"  ) to view the non strongly names assemblies ?

thanks for your help so far
Feb 19, 2009 at 2:39 AM
The strong named assemblies are the ones you are currently using, the one in the bin folder in the installation directory and it is not necessary to place them in GAC.  The unsigned ones can be located to the folder where you installed the entlib source code.  I'd like to ask again if there are any entlib blocks in your config that doesn't get loaded properly in the configuration tool?  Try again to start with a new configuration file, delete the old one and create your entlib sections using the configuration tool, the one that is in the bin folder of the installation directory.  Reference the assemblies from the same folder.


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

Feb 19, 2009 at 9:45 AM
ok, so what ive done is remove all reference to any enterprise library in the solution.  My solution has 3 projects, each with there own app.config.
I also remove the config file from the C:\Program Files\Microsoft Enterprise Library January 2006\bin\ directory and created a brand new application
within enterprise library config tool in that location.  I added the following blocks : data access application block, instrumentation, logging application block

these correspond to the entries in the app.config file from one of the projects : 

<

section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b45f42118d296492" />

 

<

section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b45f42118d296492" />

 

<

section name="instrumentationConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.Configuration.InstrumentationConfigurationSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b45f42118d296492" />

the other 2 app.config are as follows

 

<

section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

and the other one does not have any entry in there app.config at all

all 3 projects each have a reference to the 3 dlls required, which are located at the following location

C:\Program Files\Microsoft Enterprise Library January 2006\bin\Microsoft.Practices.EnterpriseLibrary.Common.dll
C:\Program Files\Microsoft Enterprise Library January 2006\bin\Microsoft.Practices.EnterpriseLibrary.Data.dll
C:\Program Files\Microsoft Enterprise Library January 2006\bin\Microsoft.Practices.EnterpriseLibrary.Logging.dll

i removed the existing windows service and re-installed it.  Still not working...
Am i missing something fundamental here ?  Anything else i can check ?  Perhaps removing  entlib 2 and re-installing it ?

 

Feb 19, 2009 at 10:48 AM
Hi,

First ensure that the other version of ent lib is removed and also manually remove the folders that has not been removed by the uninstall. So now, there is just one version of ent lib that is on your machine. I'm just a little confused, i tried installing Ent lib 2.0 and just created a simple project, added the standard app.config and data related configuration, then i suddenly noticed that my PublicKeyToken of the dataConfiguration is PublicKeyToken=null, im just wondering how you got that PublicKeyToken,. Can you try setting the PublicKeyToken to null? and see what happens?


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Feb 19, 2009 at 12:04 PM
I put "null" in the public key tokens on all enterprise library entries in the web configs and the re installed it.  The message with regards to the enterprise library
has now disappeared !  So the enterprise library part of the windows service is fine.

Thanks very much to both you and sarah, its very much appreciated
Feb 19, 2009 at 12:20 PM
glad to hear that. Thanks.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com