无法在 SQL Server 2012 中注册 stdole 程序集 [英] Cannot register stdole assembly in SQL Server 2012

查看:30
本文介绍了无法在 SQL Server 2012 中注册 stdole 程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 SQL Server 2008 迁移到 2012,但在为 CLR 例程创建一些必要的程序集时遇到了挑战.该例程依赖于 stdole.dll,但我无法创建此程序集.我的代码如下:

ALTER DATABASE main SET TRUSTWORTHY ON;创建程序集 [stdole]从'C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll'WITH PERMISSION_SET = 不安全

我收到以下错误:

警告:Microsoft .NET Framework 程序集stdole,版本=7.0.3300.0,culture=neutral,publickeytoken=b03f5f7f11d50a3a."您正在注册的未在 SQL Server 托管环境中进行全面测试,因此不受支持.将来,如果您升级或维护此程序集或 .NET Framework,您的 CLR 集成例程可能会停止工作.有关详细信息,请参阅 SQL Server 联机丛书.消息 10332,级别 16,状态 1,第 3 行程序集stdole"是使用 .NET Framework v1.0.3705 版本构建的.SQL Server 当前使用版本 v4.0.30319.

我目前使用具有系统管理员权限的帐户登录,因此我拥有 UNSAFE ASSEMBLY 权限.

请帮忙!我已经研究了几个小时,但找不到任何有效的方法.

谢谢

解决方案

关键信息在错误中指出的两个不同的 .Net 版本中:

<块引用>

程序集stdole"是使用 .NET Framework v1.0.3705 版本构建的.SQL Server 目前使用的版本是 v4.0.30319

Microsoft SQL Server 不允许混合模式 CLR.意思是,它静态链接到特定系列.SQL Server 2005、2008 和 2008 R2 链接到 2.0 系列(2.0、3.0 和 3.5),SQL Server 2012 和 2014 链接到 4.0 系列(4.0 和 4.5).可以找到更多详细信息 此处.

因此,从 SQL Server 2012 开始加载该版本的 stdole.dll 是不可能的.不幸的是,该文件夹中没有其他 DLL 链接到 4.0 系列框架.>


尝试以下操作,因为它会生成一个具有相同 publickeytoken(即 b03f5f7f11d50a3a)并在 SQL Server 2012 中成功加载的 DLL.这个想法是提取基本代码(通过 ILDASM) 然后将其重新链接到较新的框架(通过 ILASM).我不确定您的代码是否需要重新编译.

  1. 打开Visual Studio 命令提示符"/开发人员命令提示符"(不是常规的命令提示符").

  2. 运行以下语句:
    <代码>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. 在 SSMS 中运行以下命令:
    USE [main];
    CREATE ASSEMBLY [stdole] FROM 'C:\TEMP\stdole\stdole-4.0.dll' WITH PERMISSION_SET = UNSAFE;

注意事项:

I am in the process of migrating a SQL Server 2008 to 2012 and running into challenges in creating some of the necessary assemblies for a CLR routine. The routine takes a dependency on stdole.dll, but I am unable to create this assembly. My code is as follows:

ALTER DATABASE main SET TRUSTWORTHY ON;

create assembly [stdole]
from
'C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll'
WITH PERMISSION_SET = unsafe

I am receiving the following error:

Warning: The Microsoft .NET Framework assembly 'stdole, version=7.0.3300.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' you are registering is not fully tested in the SQL Server hosted environment and is not supported. In the future, if you upgrade or service this assembly or the .NET Framework, your CLR integration routine may stop working. Please refer SQL Server Books Online for more details.
Msg 10332, Level 16, State 1, Line 3
Assembly "stdole" was built using version v1.0.3705 of the .NET Framework. SQL Server currently uses version v4.0.30319.

I am currently logged in with an account that has sysadmin privileges so i have UNSAFE ASSEMBLY permissions.

Please help! I have been researching this for hours but cannot find anything that works.

Thanks

解决方案

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:

这篇关于无法在 SQL Server 2012 中注册 stdole 程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆