前几天写过一篇Blog,试验也成功了,其中有一台也是64位的操作系统。但是这几天在另外一台服务器上部署时就是不行,部署没有问题,在执行的时候报错:
消息 6522,级别 16,状态 1,过程 QueryPseudoCode,第 0 行
在执行用户定义例程或聚合 'QueryPseudoCode' 期间出现 .NET Framework 错误:
System.TypeInitializationException: The type initializer for 'StoreProc.WCF_Query' threw an exception. ---> System.IO.FileLoadException: 未能加载文件或程序集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”或它的某一个依赖项。主机存储区中的程序集与 GAC 中的程序集具有不同的签名。 (异常来自 HRESULT:0x80131050)
System.IO.FileLoadException:
at StoreProc.WCF_Query..cctor()
System.TypeInitializationException:
at StoreProc.WCF_Query.QueryPseudoCode(Byte queryType, String queryCode, String& queryResult)
。
后来找到另外一个版本的。好像是行了,为什么行了就不知道了。
EXEC sp_configure 'clr enabled', 1; RECONFIGURE WITH OVERRIDE; GO ALTER DATABASE [master] SET Trustworthy ON CREATE ASSEMBLY [System.Web] from 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Web.dll' with permission_set = UNSAFE --Fails if not 64 on 64 bit machines GO CREATE ASSEMBLY SMDiagnostics from 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\SMDiagnostics.dll' with permission_set = UNSAFE GO CREATE ASSEMBLY [System.Runtime.Serialization] from 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.Runtime.Serialization.dll' with permission_set = UNSAFE GO CREATE ASSEMBLY [System.IdentityModel] from 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.IdentityModel.dll' with permission_set = UNSAFE GO CREATE ASSEMBLY [System.IdentityModel.Selectors] from 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.IdentityModel.Selectors.dll' with permission_set = UNSAFE GO CREATE ASSEMBLY [System.Messaging] from 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Messaging.dll' with permission_set = UNSAFE GO CREATE ASSEMBLY [Microsoft.Transactions.Bridge] from 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\Microsoft.Transactions.Bridge.dll' with permission_set = UNSAFE GO ------------------------------ use master CREATE ASSEMBLY StoreProc from 'D:\StoreProcedure.dll' with permission_set = UNSAFE GO -------------------------------------------------------------- CREATE PROCEDURE [dbo].[QueryPseudoCode] ( @queryType tinyint, @queryCode nvarchar(255), @queryResult nvarchar(255) out ) WITH EXECUTE AS CALLER AS EXTERNAL NAME [StoreProc].[StoreProc.WCF_Query].[QueryPseudoCode] GO -------------------------------------------------------------- CREATE PROCEDURE [dbo].[QueryUserPosition] ( @numType tinyint, @num nvarchar(255) ) WITH EXECUTE AS CALLER AS EXTERNAL NAME [StoreProc].[StoreProc.WCF_Query].[QueryUserPosition] GO /* DROP PROCEDURE QueryPseudoCode DROP PROCEDURE QueryUserPosition DROP ASSEMBLY StoreProc DROP ASSEMBLY [Microsoft.Transactions.Bridge] DROP ASSEMBLY [System.IdentityModel.Selectors] DROP ASSEMBLY [System.IdentityModel] DROP ASSEMBLY [System.Web] DROP ASSEMBLY [System.Messaging] DROP ASSEMBLY [System.Runtime.Serialization] DROP ASSEMBLY [SMDiagnostics] */
在提示machine.config异常时,把下面所示的两行注释掉就OK了:
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config
<commonBehaviors>
<endpointBehaviors>
<!--<Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior/>-->
</endpointBehaviors>
<serviceBehaviors>
<!--<Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior/>-->
</serviceBehaviors>
</commonBehaviors>