Cannot register stdole assembly in SQL Server 2012

删除回忆录丶 提交于 2019-12-06 10:51:13

The key info is in the two different .Net versions noted in the error:

Assembly "stdole" was built using version v1.0.3705 of the .NET Framework. SQL Server currently uses version v4.0.30319

Microsoft SQL Server does not allow for mixed-mode CLR. Meaning, it is statically linked to a particular series. SQL Server 2005, 2008, and 2008 R2 are linked to the 2.0 series (2.0, 3.0, and 3.5) and SQL Server 2012 and 2014 are linked to the 4.0 series (4.0 and 4.5). More details can be found here.

So, it is impossible to load that version of stdole.dll starting in SQL Server 2012. And unfortunately there is no other DLL in that folder that is linked to a 4.0 series framework.

EDIT:
Try the following as it results in a DLL that has the same publickeytoken (i.e. b03f5f7f11d50a3a) and loads successfully in SQL Server 2012. The idea is to extract the base code (via ILDASM) and then re-link that to the newer framework (via ILASM). I am not sure if your code will need to be recompiled.

  1. Open a "Visual Studio Command Prompt" / "Developer Command Prompt" (not a regular "Command Prompt").

  2. Run the following statements:
    MKDIR C:\TEMP\stdole
    CD C:\TEMP\stdole
    XCOPY /V "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll" .
    ILDASM stdole.dll /out:stdole.il
    ILASM /DLL /OPTIMIZE /OUTPUT=stdole-4.0.dll /RESOURCE=stdole.res stdole.il

  3. Run the following in SSMS:
    USE [main];
    CREATE ASSEMBLY [stdole] FROM 'C:\TEMP\stdole\stdole-4.0.dll' WITH PERMISSION_SET = UNSAFE;

Notes:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!