Wednesday, August 17, 2011

Error using Microsoft Enterprise Library Data Application Block

I was trying to use Data Access Application Block in a Winforms application. I have added the right references including Microsoft.Practices.EnterpriseLibrary.Data

when I build the application I get this error -

1 The referenced assembly "Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.

Also, where I have referenced with using statement in classes, I was getting errors like -

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

After some googling, I got this solution which might be of help to others as well -

This is a known issue in EntLib 5.0. You must target the full .NET Framework instead of the Client Profile (Right click on project, select Properties). The Data Access Application Block has a dependency on System.Data.Oracle that has been removed from the client profile.