部署失败:CLR触发器
本文关键字:触发器 CLR 失败 部署 | 更新日期: 2023-09-27 18:20:31
我试图部署在.Net 4.0上构建的CLR触发器,但将目标框架更改为3.0,但我收到了以下错误消息。
------部署已启动:项目:ServiceClient,配置:调试任何CPU------2012年1月18日下午2:16:24开始建造。SqlClr部署:开始将程序集ServiceClient.dll部署到服务器WS037298:custDB如果部署的SQL CLR项目是为与SQL Server的目标实例不兼容的.NET Framework版本生成的,则可能会出现以下错误:"部署错误SQL01268:CREATE ASSEMBLY for ASSEMBLY失败,因为ASSEMBLY验证失败"。若要解决此问题,请打开项目的属性,然后更改.NET Framework版本。部署脚本生成为:D: ''Visual Studio 2010''Projects''ServiceClient''ServiceClient''bin''Debug''ServiceClient.sql
正在创建[ServiceClient]。。。D: ''Visual Studio 2010''Projects''ServiceClient''ServiceClient''bin''Debug''ServiceClient.sql(39-39):在sql目录中找不到部署错误SQL01268:.Net SqlClient数据提供程序:Msg 6503,级别16,状态12,第1行程序集"system.servicemodel,版本=3.0.0.0,区域性=中性,公钥令牌=b77a5c561934e089."。执行批处理时出错。
生成失败。
运行时间00:00:24.64===========生成:1成功或最新,0失败,0跳过====================部署:0成功,1失败,0跳过==========
public partial class Triggers
{
//Create an endpoint addresss for our serivce
public static EndpointAddress endpoint =
new EndpointAddress(new Uri("http://localhost:8000/services/myservice"));
//Create a binding method for our service
public static WSHttpBinding httpBinding = new WSHttpBinding();
//Create an instance of the service proxy
public static ServiceClient.ServiceReference1.ServiceContractClient myclient = new ServiceClient.ServiceReference1.ServiceContractClient(httpBinding, endpoint);
// public static ServiceClient.localhost.ServiceContractClient myClient = new ServiceClient.localhost.ServiceContractClient(httpBinding, endpoint);
//A delegate that is used to asynchrounously talk
//to the service when using the FAST METHOD
public delegate void MyDelagate(String crudType);
[SqlProcedure()]
public static void SendData(String crudType)
{
/*A very simple procedure that accepts a string parameter
based on the CRUD action performed by the
trigger. It switches based on this parameter
and calls the appropriate method on the service proxy*/
switch (crudType)
{
case "Update":
myclient.UpdateOccured();
break;
case "Insert":
myclient.InsertOccured();
break;
}
}
[Microsoft.SqlServer.Server.SqlTrigger(Name = "WCFTrigger",
Target = "tbCR", Event = "FOR UPDATE, INSERT")]
public static void Trigger1()
{
/*This is a very basic trigger that performs two very simple actions:
* 1) Gets the current trigger Context
* and then switches based on the triggeraction
* 2) Makes a call to a stored procedure
* Two methods of calling the stored procedure are presented here.
* View the article on Code Project for a discussion on these methods
*/
SqlTriggerContext myContext = SqlContext.TriggerContext;
//Used for the FAST METHOD
MyDelagate d;
switch (myContext.TriggerAction)
{
case TriggerAction.Update:
//Slow method - NOT REMCOMMEND IN PRODUCTION!
SendData("Update");
//Fast method - STRONGLY RECOMMENDED FOR PRODUCTION!
//d = new MyDelagate(SendData);
//d.BeginInvoke("Update",null,null);
break;
case TriggerAction.Insert:
//Slow method - NOT REMCOMMEND IN PRODUCTION!
SendData("Insert");
//Fast method - STRONGLY RECOMMENDED FOR PRODUCTION!
//d = new MyDelagate(SendData);
//d.BeginInvoke("Insert", null, null);
break;
}
}
它有明确的声明-它想要System.ServiceModel程序集,但没有提供。尝试首先将此程序集(可能还有其他程序集)部署到sql server
并尝试将静态字段作为局部变量移动到触发器的主体中。
如果您将程序集标记为不安全,并将数据库标记为TRUSTWORTHY,则可能会出现这种情况-在没有这些修改的情况下,