在SQL Server 2012中注册CLR功能(基于WCF)

时间:2023-01-11 01:43:05

I have a CLR based stored procedure which used MsmqIntegrationBinding to post messages to remote MSMQ's. Everything was working fine in SQL Server 2005 but now there is an upgrade from 2005 to 2012 suppose to happen. I tried to register the CLR (SP) in SQL Server 2012 but while registering System.ServiceModell.DLL it came up with the following error.

我有一个基于CLR的存储过程,它使用MsmqIntegrationBinding将消息发布到远程MSMQ。在SQL Server 2005中一切正常,但现在有一个从2005年到2012年的升级,假设发生。我尝试在SQL Server 2012中注册CLR(SP),但在注册System.ServiceModell.DLL时,它出现了以下错误。

Msg 6544, Level 16, State 1, Line 1
CREATE ASSEMBLY for assembly 'System.ServiceModel' failed because assembly 'microsoft.visualbasic.activities.compiler' is malformed or not a pure .NET assembly. Unverifiable PE Header/native stub.

Msg 6544,Level 16,State 1,Line 1 CREATE ASSEMBLY for assembly'System.ServiceModel'失败,因为程序集'microsoft.visualbasic.activities.compiler'格式错误或不是纯.NET程序集。无法验证的PE标头/本机存根。

I searched for the resolution and it appears that few other people are having the same problem and as of now there is no solution to it.

我搜索了解决方案,似乎很少有其他人遇到同样的问题,而且现在还没有解决方法。

The primary reason for using MSMQIntegrationBinding is we wanted to make sure that each message is delivered only once. As you can see that I was pretty much interested in the ExactlyOnce property which is not there in the normal system.messaging class. We process thousand of messages and ordering of messages is very important further more each message is stamped with an id and if any message is sent which has an id that is less than the message previously sent the client system halts (big problem).

使用MSMQIntegrationBinding的主要原因是我们希望确保每条消息只传递一次。正如您所看到的,我对ExactlyOnce属性非常感兴趣,而该属性在普通的system.messaging类中并不存在。我们处理数千条消息并且消息的排序非常重要,每条消息都标有一个id,如果发送的消息的id小于先前发送的消息,则客户端系统停止(大问题)。

I also have rewritten the CLR stored proc using system.messaging. I just need suggestions whether it can support the scenario I mentioned above.

我还使用system.messaging重写了CLR存储过程。我只是需要建议是否可以支持我上面提到的场景。

1 个解决方案

#1


2  

I have the same issue as you, and I don't know if there's a solution for it. What I have found is:

我和你有同样的问题,我不知道是否有解决方案。我发现的是:

There are two types of .NET assemblies. Pure .NET assemblies only contain MSIL instructions. Mixed assemblies contain both unmanaged machine instructions and MSIL instructions. Mixed assemblies in general are compiled by C++ compiler with /clr switch but contain machine instructions resulting from native C++ code.

有两种类型的.NET程序集。纯.NET程序集仅包含MSIL指令。混合程序集包含非托管机器指令和MSIL指令。混合程序集通常由带有/ clr开关的C ++编译器编译,但包含由本机C ++代码生成的机器指令。

Regardless which version of SQL Server, CREATE ASSEMBLY only allows pure .NET assemblies to be registered. SQL Server has always required that an assembly to be loaded into SQL Server database with CREATE ASSEMBLY contains only MSIL instructions (pure assembly). CREATE ASSEMBLY will raise the above error if an assembly to be registered is mixed assembly.

无论哪个版本的SQL Server,CREATE ASSEMBLY只允许注册纯.NET程序集。 SQL Server始终要求使用CREATE ASSEMBLY加载到SQL Server数据库中的程序集仅包含MSIL指令(纯程序集)。如果要注册的程序集是混合程序集,则CREATE ASSEMBLY将引发上述错误。

From http://blogs.msdn.com/b/psssql/archive/2013/02/23/unable-to-register-net-framework-assembly-not-in-the-supported-list.aspx

The point is that we really need to refer to System.ServiceModel.

关键是我们确实需要引用System.ServiceModel。

So, my guess is that, in the near future, there is no fix for it. What we have to do is code in another way.

所以,我的猜测是,在不久的将来,没有解决方案。我们要做的是以另一种方式编写代码。

#1


2  

I have the same issue as you, and I don't know if there's a solution for it. What I have found is:

我和你有同样的问题,我不知道是否有解决方案。我发现的是:

There are two types of .NET assemblies. Pure .NET assemblies only contain MSIL instructions. Mixed assemblies contain both unmanaged machine instructions and MSIL instructions. Mixed assemblies in general are compiled by C++ compiler with /clr switch but contain machine instructions resulting from native C++ code.

有两种类型的.NET程序集。纯.NET程序集仅包含MSIL指令。混合程序集包含非托管机器指令和MSIL指令。混合程序集通常由带有/ clr开关的C ++编译器编译,但包含由本机C ++代码生成的机器指令。

Regardless which version of SQL Server, CREATE ASSEMBLY only allows pure .NET assemblies to be registered. SQL Server has always required that an assembly to be loaded into SQL Server database with CREATE ASSEMBLY contains only MSIL instructions (pure assembly). CREATE ASSEMBLY will raise the above error if an assembly to be registered is mixed assembly.

无论哪个版本的SQL Server,CREATE ASSEMBLY只允许注册纯.NET程序集。 SQL Server始终要求使用CREATE ASSEMBLY加载到SQL Server数据库中的程序集仅包含MSIL指令(纯程序集)。如果要注册的程序集是混合程序集,则CREATE ASSEMBLY将引发上述错误。

From http://blogs.msdn.com/b/psssql/archive/2013/02/23/unable-to-register-net-framework-assembly-not-in-the-supported-list.aspx

The point is that we really need to refer to System.ServiceModel.

关键是我们确实需要引用System.ServiceModel。

So, my guess is that, in the near future, there is no fix for it. What we have to do is code in another way.

所以,我的猜测是,在不久的将来,没有解决方案。我们要做的是以另一种方式编写代码。