Calling a WCF Service from SQL CLR Stored Procedur

2019-05-24 01:18发布

问题:

I have created a SQL CLR Stored Procedure which will call a WCF Service. I have managed to get all the correct DLL's loaded into SQL Server to get this to work however I now have following error message:

System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for system.serviceModel/extensions: Could not load file or assembly 'System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) (C:\Windows\Microsoft.NET\Framework64\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.BaseConfigurationRecord.GetSection(String ...

I found this posting on the web but I don't know how to update the GAC or whether its actually the fix for the problem: (Invoking a WCF Service from a CLR Trigger)

回答1:

Look at Niels Berglund's blog post: http://nielsb.wordpress.com/sqlclrwcf/ You can remove the offending line from the machine.config file, or disable the debugging of WCF on the machine with vsdiag_regwcf.exe -u. You will have to recycle SQL once you make the .config file change so that it rejits the app domains.