views:

2091

answers:

2

Hi There Stackoverflow, 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.

A: 

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).

Vadim
I am using .net framework 3.5 with vs2008 sp1
Phil
+7  A: 

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.

Phil
This worked for me, though I had to clean and rebuild my solution before the changes to the DLLs took effect
tjrobinson