我正在尝试从http://www.codeproject.com/Articles/21149/Invoking-a-WCF-Service-from-a-CLR-Trigger
完成教程但是在尝试部署客户端时遇到问题,我在输出中遇到以下错误:
部署错误SQL01268:.Net SqlClient数据提供程序:消息6503,级别16,状态12,行1程序集'system.servicemodel,版本= 3.0.0.0,culture = neutral,publickeytoken = b77a5c561934e089。'在SQL目录中找不到。
我正在使用c#2010,.NET 4.0和SQL Server Express 10。
我已经尝试将项目更改为使用.NET framework 3.0和3.5但我仍然收到相同的错误。有谁知道如何解决这个问题?
修改
这可能与我在尝试将以下程序集添加到SQL Server时遇到的错误有关。
CREATE ASSEMBLY SMDiagnostics
FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\SMDiagnostics.dll'
WITH permission_set = UNSAFE
GO
CREATE ASSEMBLY [System.Web]
FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll'
WITH permission_set = UNSAFE
GO
CREATE ASSEMBLY [System.Messaging]
FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Messaging.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
-- this will add service modal
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
答案 0 :(得分:2)
经过2天的反复试验,我终于得到了它的工作,如下:
(在 Windows Server 2008 x64,SQL Server 2008 64位,使用Framework 3.0构建的程序集DLL,任何CPU )。我建议你坚持使用.Net 3 for SQL 2008。
alter database [TTBackup]
set trustworthy on;
go
USE TTBackup
--Register the assemblies referenced by our assembly.
CREATE ASSEMBLY SMdiagnostics AUTHORIZATION dbo FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\SMdiagnostics.dll' WITH permission_set = unsafe
CREATE ASSEMBLY [System.Web] AUTHORIZATION dbo FROM 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Web.dll' WITH permission_set = unsafe
CREATE ASSEMBLY [System.Runtime.Serialization] AUTHORIZATION dbo FROM 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Runtime.Serialization.dll' WITH permission_set = unsafe
CREATE ASSEMBLY [System.IdentityModel.Selectors] FROM 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.IdentityModel.Selectors.dll' with permission_set = unsafe
CREATE ASSEMBLY [System.Messaging] AUTHORIZATION dbo FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Messaging.dll' WITH permission_set = unsafe
CREATE ASSEMBLY [Microsoft.Transactions.Bridge] FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\Microsoft.Transactions.Bridge.dll' with permission_set = unsafe
--register our assembly
CREATE ASSEMBLY [TTDatabaseIntegration] AUTHORIZATION dbo FROM 'D:\TTDatabaseIntegration.dll' WITH permission_set = unsafe
GO
--Register the UDF from CLR
CREATE FUNCTION [ListImportTemplates]( ) RETURNS TABLE(TemplateID int, TemplateName NVARCHAR(4000))
AS EXTERNAL NAME [TTDatabaseIntegration].[UserDefinedFunctions].[ListImportTemplates]
GO
--Test my function
select * FROM dbo.[ListImportTemplates]()
请注意,大多数引用的DLL都是32位,但System.Web是64位。 (这是它对我有用的唯一方式)。
起初我已经注册了64位程序集,但它抛出了一个运行时异常:System.IO.FileLoadException: Could not load file or assembly 'System.ServiceModel, 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) See Microsoft Knowledge Base article 949080 for more information.
我最终将GAC中的文件(按大小)与我在SQL中注册的文件进行比较。 (GAC位于C:\ Windows \ assembly,但您无法在资源管理器中查看该文件夹,我一直在使用Total Commander。)这就是我发现GAC中的版本是32的方式。位版。
您可以使用此查询查看已注册的程序集:SELECT * FROM sys.assemblies