Connecting to Sybase database using Enterprise Library 6.0 and Sybase.ADONet4.Aseclient

Topics: Enterprise Library Core
Sep 26, 2014 at 7:53 PM
Hi

I am trying to connect to Sybase database using Sybase.ADONet4.Aseclient from Visual Studio 2013. In my project references I have added references to EnterpriseLibrary.Data.dll version= 6.0.1304.0 and EnterpriseLibrary.Data.Common.dll. But for some reason I am always getting the following error message.

The type 'Microsoft.Practices.EnterpriseLibrary.Data.Database' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null'.

If I add the EnterpriseLibrary.Data version=4.1.0.0 it is working. But I wanted to use the latest version of Enterprise Library i.e version 6.0. I tried with Enterprise Library version 5.0 and I am getting the same error message.

// code to create the database object.
Database db = new Microsoft.Practices.EnterpriseLibrary.Data.Sybase.AseDatabase(connStr);

Is there any other Sybase ADO.Net driver available for EnterpriseLibrary version 5.0 / 6.0. I have Sybase ase 15.7 installed on my machine and I am using Sybase.EnterpriseLibrary.AseClient version = 4.1.1000.0 and Sybase.ADONet4.Aseclient.dll version = 4.157.104.

Please help me with this issue.

Thanks
padma
Sep 27, 2014 at 1:52 PM
The reason you are seeing the error is that the Sybase.EnterpriseLibrary.AseClient assembly is compiled against Enterprise Library 4.1. You could ask the developer of that assembly (Sybase?) to create a new version compiled against Enterprise Library 6.

You could also try a binding redirect from version Enterprise Library 4.1.0.0 to 6.0.0.0 however the message seems to indicate the it is expecting an unsigned version of Microsoft.Practices.EnterpriseLibrary.Data since PublicKeyToken is null. If that is the case you won't be able to redirect to the signed binaries. You could always build the Enterprise Library source yourself without signing it. Then a binding redirect might work.

Another option is to decompile the Sybase Enterprise Library client (using a tool) and recompile it yourself against Enterprise Library 6. Although, I'm not sure if that is permitted by the license governing the AseClient assembly.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Sep 29, 2014 at 6:56 PM
Hi Randy,

Thank you for your reply with different option. I have tried redirect the binaries from old version to new version but it didn't work. I am not sure how to build the Enterprise Library Source with out signing it.
Is the below link is the right approach to build the source code.

http://msdn.microsoft.com/en-us/library/ff664551(v=pandp.50).aspx

Thanks
padma
Sep 30, 2014 at 10:20 PM
You can download the source code from http://www.microsoft.com/en-us/download/details.aspx?id=38789 .

Or alternately, you can get the source code from the Data Access CodePlex site and then build using a VS command line (msbuild .\build\build.proj /p:RunTests=false) or Visual Studio.

In either case, the assemblies will not be strong named (PublicKeyToken=null).

Then you can try to do a binding redirect:
 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Data.dll"
                          publicKeyToken="null"
                          culture="neutral" />
        <bindingRedirect oldVersion="4.1.0.0"
                         newVersion="6.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Oct 1, 2014 at 8:31 PM
Randy,

Thanks for the above information.

Padma.