在 SQL Server 2012 中注册 CLR 函数(基于 WCF) [英] Register CLR function (WCF based) in SQL Server 2012

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

问题描述

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

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.

消息 6544,级别 16,状态 1,第 1 行
为程序集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.

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

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).

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

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

推荐答案

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

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

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

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.

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

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.

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

重点是我们真的需要参考System.ServiceModel.

The point is that we really need to refer to 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.

这篇关于在 SQL Server 2012 中注册 CLR 函数(基于 WCF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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