Monday, February 6, 2012

The type or namespace name 'Data' does not exist in the namespace 'Microsoft.Practices.EnterpriseLibrary' (are you missing an assembly reference?)

Recently i was working on a sample WCF service project. For some database functionality, i installed EnterpriseLibrary and added the reference to the following DLL's in my project:-

i) Microsoft.Practices.EnterpriseLibrary.Data
ii) Microsoft.Practices.EnterpriseLibrary.Common

I tried to use the built in database features of EnterpriseLibrary.Data dll to do some database operation. But on building the project follwing errors were shown:-

a) The type or namespace name 'Data' does not exist in the namespace    'Microsoft.Practices.EnterpriseLibrary' are you missing an assembly reference?)    

b) The type or namespace name 'Database' could not be found (are you missing a using
  directive or an assembly reference?)

It seemed like there was some issue with the EnterpriseLibrary setup installation or DLL reference. After trying some basic stuff's, I uninstalled and installed EnterpriseLibrary multiple times but it didn't work. Tried different ways to refer the EnterpriseLibrary DLL's but that too didn't work out.

After lot of checking i found out that the issue was pretty simple.By default the WCF test project was targeted against the  .NET Framework 4 Client Profile (which was installed on my machine).

The .NET Framework 4 Client Profile target framework for the project was the only reason i was getting this DLL reference error.

[To know about the .Net Framework 4 Client Profile please refer following MSDN link:   
 http://www.microsoft.com/download/en/details.aspx?id=24872]

So i changed the targeted framework to .NET Framework 4 using the project properties.
And finally everything started working fine. A simple change in the project properties but the impact was big.

Hopefully this post can help someone to resolve this small issue and save a lot of debugging time.



Happy Coding.........

No comments :

Post a Comment