An error occurred creating the configuration section handler

Topics: Logging Application Block
Jul 17, 2008 at 7:36 PM
Maybe it's because it's the end of a long day in the company of a grizzly two year-old but I can't get my head round this.

I've created a new copy of the Enterprise Library 3.1 using the Enterprise Library Source Code Installer menu item.  I edited the solution so that contains only the Common and Logging projects.  I changed the Logging project version number to 3.1.0.1 in Assembly Information.  I then modified a couple of .cs files in the logging project and built it without any errors or warnings.

I then created a new solution, referenced the three assemblies in ...\LoggingToSpecialFolder\App Blocks\Src\Logging\bin\Release\ where LoggingToSpecialFolder is the folder into which the Enterprise Library Source Code Installer installed the whole thing and used the Enterprise Library Configuration tool to create app.config.  I added a single set of statements to create a logentry.  When I try to run it, I get this:

An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\Work\Visual Studio 2008\Projects\UnderstandingEnterpriseLibrary\LoggingBlockTest1\bin\Debug\LoggingBlockTest1.vshost.exe.config line 3)

I would be very grateful if someone would point out where I'm being stupid.

Thanks in advance.
Jul 17, 2008 at 10:03 PM

Hi,

The configuration tool built together with the signed 3.1 binaries will only spit out configuration referencing classes in those binaries; at runtime the assembly that can be found does not match the type name saved by the tool, causing the failure.

You can either build a new version of the tool for your new binaries, which will force you to include the design time support binaries for at least the runtime projects you want to use, or just update the assembly qualified type names in the app.config file generated by the tool to match your new assemblies (most likely, changing the Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a to Version=3.1.0.1, Culture=neutral, PublicKeyToken=null unless you've signed your binaries); the latter will of course render the configuration tool unable to open the updated configuration file, so the former is preferred.

Hope this helps,
Fernando


SSG31415926 wrote:
Maybe it's because it's the end of a long day in the company of a grizzly two year-old but I can't get my head round this.

I've created a new copy of the Enterprise Library 3.1 using the Enterprise Library Source Code Installer menu item.  I edited the solution so that contains only the Common and Logging projects.  I changed the Logging project version number to 3.1.0.1 in Assembly Information.  I then modified a couple of .cs files in the logging project and built it without any errors or warnings.

I then created a new solution, referenced the three assemblies in ...\LoggingToSpecialFolder\App Blocks\Src\Logging\bin\Release\ where LoggingToSpecialFolder is the folder into which the Enterprise Library Source Code Installer installed the whole thing and used the Enterprise Library Configuration tool to create app.config.  I added a single set of statements to create a logentry.  When I try to run it, I get this:

An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\Work\Visual Studio 2008\Projects\UnderstandingEnterpriseLibrary\LoggingBlockTest1\bin\Debug\LoggingBlockTest1.vshost.exe.config line 3)

I would be very grateful if someone would point out where I'm being stupid.

Thanks in advance.


Jul 18, 2008 at 10:36 AM
It does, indeed.  I figured out the first part as I was brushing my teeth, last night - funny when these things come to you, isn't it?  But I'm not sure I would've thought of your first suggestion and I didn't know about PublicKeyToken=null  so, I'd probably just have blanked the version/culture/publickeytoken bit.  Yee-harrrr, etc.!

Thanks very much.
Jul 18, 2008 at 1:36 PM
That's so true; nothing like stop thinking about something to figure it out, huh?

One last thing; if you want to use the IDE integrated configuration tool you need to learn about configuration sets. Setting up a configuration set for the integrated tool is the equivalent of building your own standalone tool.

Regards,
Fernando


SSG31415926 wrote:
It does, indeed.  I figured out the first part as I was brushing my teeth, last night - funny when these things come to you, isn't it?  But I'm not sure I would've thought of your first suggestion and I didn't know about PublicKeyToken=null  so, I'd probably just have blanked the version/culture/publickeytoken bit.  Yee-harrrr, etc.!

Thanks very much.