简体   繁体   English

SQL Server 2012 CLR错误创建程序集

[英]SQL Server 2012 CLR Error creating assembly

I've to send Google Client Messaging (GCM) Notifications from SQL Server when a row is inserted into a specific table. 当在特定表中插入一行时,我必须从SQL Server发送Google客户端消息(GCM)通知。

I created a Service Broker to manage queue and so on my table, I use a trigger on insert operations to add a "work" to my queue. 我创建了一个Service Broker来管理队列,等等,在表上,我在插入操作上使用了触发器,以将“工作”添加到队列中。

I want my Service Broker to call a CLR procedure to send GCM Notification and I created it in Visual Studio. 我希望我的Service Broker调用CLR过程来发送GCM通知,并在Visual Studio中创建了它。

My problem is that when I try to create an assembly in SQL Server I get many errors and it seems that many other framework dlls are needed (for example System.Runtime ...etc). 我的问题是,当我尝试在SQL Server中创建程序集时,出现很多错误,并且似乎还需要许多其他框架dll(例如System.Runtime ... etc)。

Can anyone tell me why ? 谁能告诉我为什么? Any suggestions? 有什么建议么?

Thanks in advance 提前致谢

SQLCLR is a very restricted / limited environment. SQLCLR是一个非常受限制的环境。 The MSDN page for Supported .NET Framework Libraries lists the DLLs that are guaranteed to work. 支持的.NET Framework库的MSDN页面列出了可以保证工作的DLL。 If your project is referencing a DLL that is not in that list, then you will have to attempt loading it manually. 如果您的项目所引用的DLL不在该列表中,那么您将不得不尝试手动加载它。 This, however, is not guaranteed to work, or if it does work, it is not guaranteed to continue working across updates of the .NET Framework or SQL Server. 但是,不能保证此方法可以正常工作,或者不能保证可以在.NET Framework或SQL Server的更新之间继续工作。 For a lot more detail on the nuances of working within SQL Server's CLR host, please see the following article that I wrote (free registration is required for that site): 有关在SQL Server CLR主机中工作的细微差别的更多详细信息,请参阅我写的以下文章(该站点需要免费注册):

Stairway to SQLCLR Level 5: Development (Using .NET within SQL Server) 通往SQLCLR 5级的阶梯:开发(在SQL Server中使用.NET)

Now, it seems that you are trying to use Google Clould (not Client) Messaging: Overview . 现在,您似乎正在尝试使用Google Clould(而非客户端)消息传递: 概述 From what I can see in that documentation, the easiest and most stable means of communicating to a GCM connection server is to use the HTTP protocol, construct the JSON manually (this should be pretty easy to do), and call the GCM server using HttpWebRequest . 从该文档中我可以看到,与GCM连接服务器通信的最简单,最稳定的方法是使用HTTP协议,手动构造JSON(这应该很容易做到),然后使用HttpWebRequest调用GCM服务器。

The reason I am suggesting to construct the JSON "by hand" is because DataContractJsonSerializer exists within System.Runtime.Serialization.dll and that is not one of the supported .NET Framework libraries (as previously mentioned). 我建议“手动”构造JSON的原因是因为DataContractJsonSerializer存在于System.Runtime.Serialization.dll中 ,并且不是受支持的.NET Framework库之一(如前所述)。 Since you are already using HTTP, you should just need to remove the .NET JSON serialization and instead use StringBuilder to construct it. 由于您已经在使用HTTP,因此您只需要删除.NET JSON序列化,而是使用StringBuilder来构造它。 Don't forget to remove the reference to System.Runtime.Serialization from your project. 不要忘记从项目中删除对System.Runtime.Serialization的引用。

I have some additional info in these answers: 我在这些答案中有一些其他信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM