【发布时间】:2012-02-12 20:31:24
【问题描述】:
我正在尝试部署基于 .Net 4.0 构建的 CLR 触发器,但将目标框架更改为 3.0,但我收到以下错误消息。
------ 部署开始:项目:ServiceClient,配置:调试任何 CPU ------ 构建于 2012 年 1 月 18 日下午 2:16:24 开始。 SqlClr部署: 开始将程序集 ServiceClient.dll 部署到服务器 WS037298:custDB 如果部署为与 SQL Server 目标实例不兼容的 .NET Framework 版本构建的 SQL CLR 项目,则可能会出现以下错误:“部署错误 SQL01268:为程序集创建程序集失败,因为程序集验证失败”。要解决此问题,请打开项目的属性,然后更改 .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): 部署错误 SQL01268: .Net SqlClient 数据提供者: Msg 6503, Level 16, State 12, Line 1 Assembly 'system .servicemodel,版本=3.0.0.0,文化=中性,publickeytoken=b77a5c561934e089。在 SQL 目录中找不到。 执行批处理时出错。
构建失败。
经过时间 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;
}
}
【问题讨论】:
-
谢谢汉斯,我已经按照 Humanworkflow 中的建议做了,但我仍然有问题,看来我必须对我的 WCF 做点什么
-
嗯,您在 Oleg 的回答中留下的评论表明您现在收到了完全不同的错误消息。 msdn.microsoft.com/en-us/library/ms403273.aspx
-
基于少数博客,我强烈怀疑我必须不安全的一些组装,但无论你要求在“humanworkflow”中创建什么组装,它都是不安全的。我不知道我必须不安全的组装现在开始部署这个项目
-
我再次重新检查安装在我的 sqlserver 中的程序集都是不安全的。
标签: c# sql-server triggers