简体   繁体   English

更新实体框架后,我的CLR StoredProcedure停止工作,直到我再次对其进行编译

[英]After updating Entity Framework my CLR StoredProcedure stopped working until I compiled it again

I ask this question before sql server clr-how to call wcf service in clr sql stored procedure in visual studio and create a stored procedure to call wcf service but when I update entity framework 4.5 to 4.5.1 on my server stored procedure not work and its error around of System.ServiceModel assembly 我在sql server clr之前问这个问题-如何在Visual Studio的clr sql存储过程中调用wcf服务并创建stored procedure以调用wcf service但是当我在服务器存储过程中将实体框架4.5更新为4.5.1时,围绕System.ServiceModel程序集的错误
I forced to do all step in answer of my old question and publish stored procedure again to work. 我不得不回答我的旧问题,并再次发布存储过程以使其正常工作。

but I confused, because my sql server is 2008 r2 and it work with entity framework 3.5, why I must republish my stored procedure and all steps Can any one help me? 但是我感到困惑,因为我的sql server是2008 r2,并且它可以与实体框架3.5一起使用,为什么我必须重新发布存储过程和所有步骤,有人可以帮助我吗?

I think your way to solve problem is not correct, 我认为您解决问题的方法不正确,
For Call WCF Service in SQL Server you must use System.Web.Service instead of System.ServiceModule 对于SQL Server呼叫WCF服务,您必须使用System.Web.Service而不是System.ServiceModule
I you use this assembly you do not force to add 如果您使用此程序集,则不强制添加

  • System.Messaging System.Messaging
  • System.IdentityModel System.IdentityModel
  • System.IdentityModel.Selectors System.IdentityModel.Selectors
  • Microsoft.Transactions.Bridge Microsoft.Transactions.Bridge
  • System.Runtime.Serialization System.Runtime.Serialization
  • System.ServiceModel System.ServiceModel

this way is very simple, just add service like old web service 这种方法非常简单,只需添加服务,例如旧的Web服务
for more information use Calling WCF in CLR 有关更多信息,请使用CLR中的调用WCF。

The reason you got the error on System.ServiceModel is because: 您在System.ServiceModel上收到错误的原因是:

  • You loaded System.ServiceModel.dll into SQL Server as it is not a supported .Net Framework library 您将System.ServiceModel.dll加载到SQL Server中,因为它不是受支持的.Net Framework库

  • You updated the main System.ServiceModel.dll , probably as part of upgrading Entity Framework 您更新了主System.ServiceModel.dll ,可能是升级Entity Framework的一部分

  • The version of the DLL loaded into SQL Server no longer matched the version of the DLL in the GAC 加载到SQL Server中的DLL版本不再与GAC中的DLL版本匹配

  • The version of the DLL loaded into SQL Server must match the version of the DLL in the GAC: 加载到SQL Server中的DLL版本必须与GAC中的DLL版本匹配:

    If you have unsupported libraries registered in a SQL Server database, your SQL Server application may stop working ... because servicing or upgrading libraries in the GAC does not update assemblies inside SQL Server. 如果您在SQL Server数据库中注册了不受支持的库,则您的SQL Server应用程序可能会停止运行...因为GAC中的服务或升级库不会更新SQL Server中的程序集。 If an assembly exists both in a SQL Server database and in the GAC, the two copies of the assembly must exactly match. 如果程序集同时存在于SQL Server数据库和GAC中,则该程序集的两个副本必须完全匹配。 If they do not match, an error will occur when the assembly is used by SQL Server CLR integration. 如果它们不匹配,则SQL Server CLR集成使用该程序集时将发生错误。

    ( Breaking Changes in SQL Server 2008/SQL Server 2008R2 ) SQL Server 2008 / SQL Server 2008R2中的重大更改


And I think I just found the exact error that you ran into. 我想我只是找到了您遇到的确切错误。 Check out this page: 查看此页面:

Error message when you execute a CLR routine or use an assembly in SQL Server: "Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)" 当您执行CLR例程或在SQL Server中使用程序集时出现错误消息:“主机存储区中的程序集与GAC中的程序集具有不同的签名。(HRESULT的异常:0x80131050)

Which states (in "Scenario 1"): 哪些状态(在“方案1”中):

You create a common language runtime (CLR) routine that references a Microsoft .NET Framework assembly. 您创建引用Microsoft .NET Framework程序集的公共语言运行库(CLR)例程。 The .NET Framework assembly is not documented in Knowledge Base article 922672. Then, you install the .NET Framework 3.5 or a .NET Framework 2.0-based hotfix. 知识库文章922672中没有记录.NET Framework程序集。然后,您安装.NET Framework 3.5或基于.NET Framework 2.0的修补程序。

That scenario supports what I had mentioned above the line. 这种情况支持我上面提到的内容。

I had a related error some time ago. 我前段时间有一个相关的错误。 The thrown error was: 引发的错误是:

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 无法从程序集'System.ServiceModel,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.ServiceModel.Activation.HttpModule'

This error can occurrs when IIS is installed/updated after .NET Framework 4 has been installed, or whether the module Http Activation v3.0 is installed after .NET Framework 4 has been installed. 在安装.NET Framework 4之后安装或更新IIS,或者在安装.NET Framework 4之后是否安装了模块Http Activation v3.0时,可能会发生此错误。 Whatever, the problem as you mentioned, was the update of the EF. 无论如何,您提到的问题是EF的更新。

Maybe this can be helpful: 也许这会有所帮助:

  • Run the tool ASP.NET IIS Registration Tool (Aspnet_regiis.exe) 运行工具ASP.NET IIS注册工具(Aspnet_regiis.exe)
  • Run the command to register the new version: 运行命令以注册新版本:
    C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319>aspnet_regiis.exe –iru

You can get more info here: 您可以在此处获取更多信息:

Or maybe you want to update a library in the GAC . 或者,也许您想更新GAC中的库。 The libraries of the framework are cached in the GAC , check this article How to: Install an Assembly into the Global Assembly Cache and this topic Updating a DLL in the GAC 该框架的库已缓存在GAC中 ,请检查本文如何:将程序集安装到全局程序集缓存中,以及本主题在GAC中更新DLL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM