部署失败:CLR触发器 [英] Deploy Failed : CLR Trigger

查看:81
本文介绍了部署失败:CLR触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试部署基于.Net 4.0的CLR触发器,但将目标框架更改为3.0,但出现了以下错误消息。

Am trying to deploy my CLR Trigger built on .Net 4.0 but changed the target framework to 3.0 but i got the below error message.


------部署开始:项目:ServiceClient,配置:调试任何CPU ------
构建开始于18/01/2012 2:16:24 PM。
SqlClrDeploy:
开始将程序集ServiceClient.dll部署到服务器WS037298:custDB
如果您部署针对.NET Framework版本构建的SQL CLR项目,则可能会出现以下错误。与SQL Server的目标实例不兼容:部署错误SQL01268:为程序集创建装配失败,因为程序集验证失败。要解决此问题,请打开项目的属性,然后更改.NET Framework版本。
部署脚本生成为:
D:\Visual Studio 2010\Projects\ServiceClient\ServiceClient\bin\Debug\ServiceClient.sql

------ Deploy started: Project: ServiceClient, Configuration: Debug Any CPU ------ Build started 18/01/2012 2:16:24 PM. SqlClrDeploy: Beginning deployment of assembly ServiceClient.dll to server WS037298 : custDB The following error might appear if you deploy a SQL CLR project that was built for a version of the .NET Framework that is incompatible with the target instance of SQL Server: "Deploy error SQL01268: CREATE ASSEMBLY for assembly failed because assembly failed verification". To resolve this issue, open the properties for the project, and change the .NET Framework version. Deployment script generated to: D:\Visual Studio 2010\Projects\ServiceClient\ServiceClient\bin\Debug\ServiceClient.sql

创建[ServiceClient] ...
D:\Visual Studio 2010\项目\ServiceClient\ServiceClient\bin\Debug\ServiceClient.sql(39-39):部署错误SQL01268:.Net SqlClient数据提供程序:消息6503,级别16,状态12,第1行,程序集 system.servicemodel,版本= 3.0.0.0,区域性=中性,publickeytoken = b77a5c561934e089。未找到。
执行批处理时发生错误。

Creating [ServiceClient]... D:\Visual Studio 2010\Projects\ServiceClient\ServiceClient\bin\Debug\ServiceClient.sql(39-39): Deploy error SQL01268: .Net SqlClient Data Provider: Msg 6503, Level 16, State 12, Line 1 Assembly 'system.servicemodel, version=3.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.' was not found in the SQL catalog. An error occurred while the batch was being executed.

构建失败。

已用时间00 :00:24.64
==========构建:1成功或最新,0失败,0跳过==========
== ========部署:0成功,1失败,0跳过===========

Time Elapsed 00:00:24.64 ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ========== ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========



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

It is clearly stated - it wants System.ServiceModel assembly, which is not supplied. Try to deploy this assembly (and may be some others) to sql server first

并尝试将静态字段作为局部变量移入触发器主体。

And try to move your static fields into the body of trigger as local variables.

可能是这样,如果您将程序集标记为UNSAFE,而数据库标记为TRUSTWORTHY-则无需进行这些修改即可工作

May be if you mark your assembly as UNSAFE and database as TRUSTWORTHY - it will work without these modifications

这篇关于部署失败:CLR触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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