Showing posts with label EnterpriseLibrary. Show all posts
Showing posts with label EnterpriseLibrary. Show all posts

Friday, June 15, 2012

The referenced assembly could not be resolved because it has a dependency on "System.Data.OracleClient, Version=4.0.0.0

One of my friend was having trouble in compiling the application.  He saw the following warning message in Visual Studio. Since he was accessing the SQL server he neglected it. He didn't reference Oracle from any of his projects in the solution. He emailed me the solution , I checked the code and dint find anything wrong there.


The referenced assembly 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




Solution:


Change the application Framework Target from .Net Framework Client Profile to Main

Root Cause:
.NET Framework 4 Client Profile does not include .NET Framework Data Provider for Oracle. Since Microsoft.Practices.EnterpriseLibrary.Data has a reference to System.Data.OracleClient this error is thrown.

Sunday, June 3, 2012

DatabaseFactory.CreateDatabase error- Object synchronization method was called from an unsynchronized block of code.

Yesterday one of my friends called me and said that he was getting an unusual exception form one of the projects which I had created long back. The only change he made was to add the latest Microsoft.Practices.EnterpriseLibrary  library 5.0.414.0

The error was 
 Object synchronization method was called from an unsynchronized block of code.

The error observed was at the following line

Database db = DatabaseFactory.CreateDatabase(_conStringName);

This was a code which was runninig successfully foer years. Initially I suepected trhat my firend had accidentyly made some mistake but when I reviewed the code I didn’t see much changes. I quickly made the following changes in the code & it worked !!!
SqlDatabase db = new SqlDatabase(_conStringName);

I think Microsoft should be more careful in making such changes which affect the existing runninig code.