problem with Data.dll (issue with Unity.dll)

Topics: Data Access Application Block, Enterprise Library Core, General discussion
Nov 27, 2011 at 5:20 AM
Edited Nov 27, 2011 at 5:21 AM

I am working on an application where i am using Data.dll of pattern Library

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Collections;
//using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
//using Microsoft.Practices.Unity;
using System.Collections.Specialized;

 public static int GetInt(string SpName, System.Collections.Generic.List<GenralizeParametre> ParametreList)
        {

            int intReturn = 0;
            Database db = DatabaseFactory.CreateDatabase();
            using (DbCommand dbCommand = db.GetStoredProcCommand(SpName))
            {
                foreach (GenralizeParametre param in ParametreList)
                {
                    db.AddInParameter(dbCommand, param.ParamName, param.ParamDbType, param.ParamValue);
                }
                intReturn = Convert.ToInt32(db.ExecuteScalar(dbCommand));

                dbCommand.Dispose();
            }
            return intReturn;
        }

I have worked with this data library in my last project without any issues but now for the same configuration,

now on

      Database db = DatabaseFactory.CreateDatabase();

statement, I am getting error of Unity.dll. like could not find assembly reference Unity.dll and if i include the Unity.dll from same buid of library it gives me error about version.... i have tried with both entlib 4.0 and 5.0 dlls.........

 

This error comes suddenly without any change in project sometimes it resolves automatically.

what could be the desired permanent  solution for this .........?

is there any way of removing Unity.dll Usage from Data.dll as i said it worked perfactly previously

Nov 27, 2011 at 6:40 AM

Microsoft.Practices.EnterpriseLibrary.Data.dll is dependent on Unity so you will need to be able to resolve Microsoft.Practices.Unity.dll.

Some things to check:

  • Ensure that the reference to the Microsoft.Practices.* assemblies are from the correct location
  • Ensure that the version of assemblies being referenced is correct (for 5.0.505.0 you need Unity 2.1.505.0 and for 5.0.414.0 you need Unity 2.1.414.0)
  • Are you sure that all assemblies have been deployed to the proper locations so that the runtime can resolve them?
  • Check the configuration file to ensure that the configuration also uses the correct EntLib version numbers.

To troubleshoot the issue you can use the Assembly Binding Log Viewer to provide detailed binding information.

I've also found that adding references with nuget can help with dependency management.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com

Nov 27, 2011 at 6:43 AM

Also, as an aside: I noticed you are calling dbCommand.Dispose(); which you don't need to do since you have dbCommand in a using statement.  

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com

Nov 27, 2011 at 9:26 AM

 nuget seems to be the best solution but i can not work with VS2010 we use VS2008 is there any way to use nuget for VS2008??

Nov 27, 2011 at 4:28 PM

nuget only supports Visual Studio 2010.  However, it does look like SharpDevelop supports nuget and will run in Visual Studio 2008 so that might be a way of getting that functionality.
I haven't tried SharpDevelop so if you do I would be curious to hear if it works for you.

 

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com

Nov 28, 2011 at 4:44 AM

it worked

you can see screen shot

http://bayimg.com/OaLnFaADB

thank you  for suggestion...............