C#/SQL Server 2012 Assembly dependencies error

0

I created a custom assembly using C# that has the following dependencies:

  1. Newtonsoft.Json.dll
  2. SMDiagnostics.dll
  3. System.ServiceModel.Internals.dll
  4. System.Runtime.Serialization.dll

This assembly then is being loaded into SQL Server 2012 to be executed by a SQL function.

When I Create the assembly on SQL Server 2012 Express running .NET v4.0 on my LOCAL MACHINE, it runs fine and I'm able to execute the function and the code block inside the assembly. Nevertheless, when I move this to a server that is running SQL Server 2012 and .NET v3.5, I get the following error:

Msg 6522, Level 16, State 1, Line 1 A .NET Framework error occurred during execution of user-defined routine or aggregate "GetOutagesFunc": System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information.

The custom assembly and all of its' dependencies were installed with no errors and when I compared the versions of all assemblies on the server, they match the versions on all the assemblies in my local machine.

I though that maybe because the server is running .NET v 3.5 I was not able to target my assembly to a version higher than 3.5 so I targeted my assembly to a .NETv3.5, but I'm still having the same issue.

Any guidance is appreciated.

c#
sql-server
clr
asked on Stack Overflow Feb 10, 2016 by jorgeAChacon • edited Feb 11, 2016 by jorgeAChacon

1 Answer

0

I am also having same issue while running nUnit test. The CLR and code is using 4.0.0 version and GAC has 3.0.0 version. When the test runs, the assembly version is different in GAC and CLR.

I found similar thread... SQLCLR Function and System.Runtime.Serialization In GAC. It may help in your situation.

I tried to copy the new version to GAC but copy was not successful. it may be due to other dependencies of serialization dll.

answered on Stack Overflow Dec 22, 2016 by tomcat • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0