Cha*_*ams 2 sql-server sqlclr sql-server-2012
我正在将SQL Server 2008迁移到2012,并在为CLR例程创建一些必要的程序集时遇到了挑战.例程依赖于stdole.dll,但我无法创建此程序集.我的代码如下:
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
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
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.
Run Code Online (Sandbox Code Playgroud)
我目前使用具有sysadmin权限的帐户登录,因此我有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).更多细节可以在这里找到.
因此,无法stdole.dll在SQL Server 2012中加载该版本的启动.不幸的是,该文件夹中没有其他DLL链接到4.0系列框架.
编辑:
尝试以下,因为它导致具有相同的DLL publickeytoken(即b03f5f7f11d50a3a)并在SQL Server 2012中成功加载.想法是提取基本代码(通过ILDASM),然后将其重新链接到更新的框架(通过ILASM).我不确定您的代码是否需要重新编译.
打开"Visual Studio命令提示符"/"开发人员命令提示符"(不是常规的"命令提示符").
运行以下语句:
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
在SSMS中运行以下命令:
USE [main];
CREATE ASSEMBLY [stdole] FROM 'C:\TEMP\stdole\stdole-4.0.dll' WITH PERMISSION_SET = UNSAFE;
笔记:
stdole.dll? http://msdn.microsoft.com/en-us/library/aa195478(office.11).aspxstdole.res作为ILASM命令参数提到的文件由命令创建ILDASM; 它没有明确说明像输出文件那样stdole.il.| 归档时间: |
|
| 查看次数: |
1147 次 |
| 最近记录: |