插入/更新表时CLR触发器引发异常 [英] CLR Trigger throwing exception when insert/update the table

查看:68
本文介绍了插入/更新表时CLR触发器引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

首先,我要感谢帮助我解决有关CLR触发器的问题,现在它已部署并正在尝试启动测试,在插入或更新记录并终止记录时会抛出错误.

错误:

消息6522,第16级,状态1,程序WCFTrigger,第1行
在执行用户定义的例程或聚合"WCFTrigger"的过程中发生了.NET Framework错误:
System.TypeInitializationException:触发器"的类型初始值设定项引发了异常. ---> System.Configuration.ConfigurationErrorsException:类型"Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior,Microsoft.VisualStudio.Diagnostics.ServiceModelSink,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a"已注册为扩展名"Microsoft".无法加载VisualStudio.Diagnostics.ServiceModelSink.Behavior''. (C:\ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ Config \ machine.config第185行)
System.Configuration.ConfigurationErrorsException:
在System.Configuration.BaseConfigurationRecord.EvaluateOne(String []键,SectionInput输入,Boolean isTrusted,FactoryRecord factoryRecord,SectionRecord sectionRecord,对象parentResult)
在System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord,SectionRecord sectionRecord,Object parentResult,Boolean getLkg,Boolean getRuntimeObject,Object&,Object& resultRuntimeObject)
在System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey,布尔getLkg,布尔checkPermission,布尔getRuntimeObject,布尔requestIsHere,Object&结果,Object& resultRuntimeObject)
在System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey,布尔getLkg,布尔checkPermission,布尔getRuntimeObject,布尔requestIsHere,Object&结果,Object& resultRuntimeObject)
在System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey,布尔getLkg,布尔checkPermission,布尔getRuntimeObject,布尔requestIsHere,Object&结果,Object& resultRuntimeObject)
在System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey,布尔getLkg,布尔checkPermission,布尔getRuntimeObject,布尔requestIsHere,Object&结果,Object& resultRuntimeObject)
在System.Configuration.BaseConfi ...
该声明已终止.



在我的表格中创建的触发器:

Hi All,

I would thank first to help me for my earlier issues with CLR Trigger,now it got deployed and am trying to start test,it throws error when am insert or update the record and it terminates.

Error:

Msg 6522, Level 16, State 1, Procedure WCFTrigger, Line 1
A .NET Framework error occurred during execution of user defined routine or aggregate ''WCFTrigger'':
System.TypeInitializationException: The type initializer for ''Triggers'' threw an exception. ---> System.Configuration.ConfigurationErrorsException: The type ''Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior, Microsoft.VisualStudio.Diagnostics.ServiceModelSink, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'' registered for extension ''Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior'' could not be loaded. (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 185)
System.Configuration.ConfigurationErrorsException:
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfi...
The statement has been terminated.



The trigger created in my table :

CREATE TRIGGER [WCFTrigger] ON [dbo].[tbCR]  AFTER  INSERT, UPDATE AS 
EXTERNAL NAME [ServiceClient].[Triggers].[Trigger1]
GO
EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFile', @value=N'WCFTrigger.cs' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'tbCR', @level2type=N'TRIGGER', @level2name=N'WCFTrigger'

GO
EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFileLine', @value=N'55' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'tbCR', @level2type=N'TRIGGER', @level2name=N'WCFTrigger'




请有人告诉我这里缺少什么.我正在VS 2010上运行,但目标Frame工作是3.0.

在此先感谢




Please some one throw me a light what am missing here.Am running on VS 2010 but target Frame work is 3.0.

Thanks in Advance

推荐答案

look man尝试在您的数据库中运行此脚本

look man try to run this script in your Database

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO




启用CLR有时会出现类似这些错误,但是要小心,如果您可能会在应用程序中使用云...不能在云窗口中使用clr,请务必注意
问候




it is to enable th CLR sometimes it gives like these errors but take care if you may go to cloud in your application...you cant use clr in cloud windows azure take care about that
regards


这篇关于插入/更新表时CLR触发器引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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