Problem when trying to configure enterprise library 5.0 (Data Access Application Block)
Asked Answered
T

6

13

I am running into some problems while trying to get DAAB from Enterprise library 5.0 running. I have followed the steps as per the tutorial, but am getting errors...

1) Download / install enterprise library

2) Add references to the blocks I need (common / data)

3) Imports

Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data

4) Through the enterprise library config software. I open up the web.config from my site. I then click Blocks, then Add data settings... fill in my details and save / close

5) I then (thinking setup is complete) try to get an instance of the database via

 Dim db As Database = DatabaseFactory.CreateDatabase() 

6) I compile and receive the following error:

Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\site\web.config line 4)

Line 4 off my web.config was generated by the config tool and is:

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />

Am I missing a required step? Have I done the steps in the wrong order? Have I made a mistake?

Thanks a lot for the assistance.

Toothy answered 17/5, 2010 at 13:27 Comment(0)
T
20

The answer:

I had accidentaly referenced the assemblies from the src code folder. Which means the public tokens would have = null. I re-referenced to the assemblies in C:\Program Files\Microsoft Enterprise Library 5.0\Bin and the problem is now solved.

Toothy answered 18/5, 2010 at 8:10 Comment(1)
This worked for me, though I had to clean and rebuild my solution before the changes to the DLLs took effectHannis
S
4

I already saw you got the answer; however, I wanted to point out that when you open the Config tool from VS, you have the option to tell the config tool what assemblies you want to have referenced:

  1. In VS2010: open the properties editor window, and select from the solution explorer the Solution file.
  2. You'll see the option "Enterprise Library 5 Assembly Set, with the options to use the signed versions (Microsoft Signed) or the unsigned (EntLibV5Src)

When you fire up the config tool; it will reference the assemblies in the config file accordingly to your choice.

Sergu answered 8/2, 2011 at 15:57 Comment(1)
This worked for me. One additonal point: If your config file already had some EntLib specific things in it that were referenced as signed and you want to use unsingned versions of EntLib libraries, you need to manually remove PublicKeyToken= from your config file wherever it is used in EntLib context. Otherwise ConfigEditor won't open and you will get the same excetion.Acrosstheboard
U
3

In addition to what @Nicolas answered you can over come this problem by removing public token in app.config where ever it being used with Enterprise Library 5.0 dll

Upchurch answered 19/5, 2011 at 11:44 Comment(0)
K
2

Enterprise library has 2 downloads ...

  • Enterprise Library 5.0 - Source Code.msi
  • Enterprise Library 5.0.msi

Only the second one has the signed binaries ... which is what's necessary to resolve the "manifest definition does not match the assembly reference" error

(and FYI, the second one also includes the source code if you elect to install it)

Kaisership answered 6/4, 2011 at 18:52 Comment(1)
There is also an Enterprise Library 5.0 Optional Update 1. Its version is 5.0.505.0 and will cause the error if it is installed in place of Enterprise Library 5.0 for an existing project.Detailed
A
1

What probably you need to do is change Target framework in property of your project from ".NET Framework 4 Client Profile" to ".NET Framework 4".

When you first create a console project, VS 2010 by default creates ."NET Framework 4 Client Profile". EL 5 compiled with ".NET Framework 4" and your project has hard time to resolve EL dll(s).

Astonish answered 17/5, 2010 at 13:50 Comment(0)
A
1

generate

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />                      
        <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />   
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />      
Altercate answered 25/5, 2011 at 21:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.