Visual studio 2010 SQL Server找不到序列化程序集

Visual studio 2010 SQL Server找不到序列化程序集,visual-studio-2010,web-services,sql-server-2008,serialization,sqlclr,Visual Studio 2010,Web Services,Sql Server 2008,Serialization,Sqlclr,我正在尝试部署一个调用Web服务的UpdateContentriesSQLCRL过程,下面是这里的帮助 footheory.com/blogs/bennie/archive/2006/12/07/invoking-a-web-service-from-a-sqlclr-storage-procedure.aspx 基本上,我在VisualStudio2010上有一个Visual C#SQL CLR数据库项目,其中有一个简单的过程,该过程调用作为Web引用添加的外部Web服务 我已将项目复

我正在尝试部署一个调用Web服务的UpdateContentriesSQLCRL过程,下面是这里的帮助

  • footheory.com/blogs/bennie/archive/2006/12/07/invoking-a-web-service-from-a-sqlclr-storage-procedure.aspx
基本上,我在VisualStudio2010上有一个Visual C#SQL CLR数据库项目,其中有一个简单的过程,该过程调用作为Web引用添加的外部Web服务

我已将项目复制到保存SQL server 2008数据库的远程服务器

在项目属性中,我已将生成序列化程序集设置为“开”,将数据库权限级别设置为“外部”,并激活了部署代码

在项目中,我还手动创建并删除序列化程序集,如下所示:

PreDeployScript.sql

IF EXISTS (SELECT [name] FROM sys.assemblies WHERE [name] = N'ReportsWebServicesXML')
    DROP ASSEMBLY [ReportsWebServicesXML];
GO
CREATE ASSEMBLY [ReportsWebServicesXML]
    FROM 'E:\Projects\Reports\ReportsWebServices\ReportsWebServices\bin\Debug\ReportsWebServices.XmlSerializers.dll'
    WITH PERMISSION_SET = SAFE;
GO
PostDeployScript.sql

IF EXISTS (SELECT [name] FROM sys.assemblies WHERE [name] = N'ReportsWebServicesXML')
    DROP ASSEMBLY [ReportsWebServicesXML];
GO
CREATE ASSEMBLY [ReportsWebServicesXML]
    FROM 'E:\Projects\Reports\ReportsWebServices\ReportsWebServices\bin\Debug\ReportsWebServices.XmlSerializers.dll'
    WITH PERMISSION_SET = SAFE;
GO
项目构建和部署成功后,我可以在Assembies文件夹下的Visual Studio 2010 Server explorer中看到ReportsWebServicesReportsWebServices XML,但当我尝试运行该过程时,它仍然返回以下错误:

Msg 6522, Level 16, State 1, Procedure UpdateContries, Line 0
A .NET Framework error occurred during execution of user-defined routine or aggregate "UpdateContries": 
System.InvalidOperationException: Cannot load dynamically generated serialization assembly. In some hosting environments assembly load functionality is restricted, consider using pre-generated serializer. Please see inner exception for more information. ---> System.IO.FileLoadException: LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host.
System.IO.FileLoadException: 
   at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection)
   at System.Reflection.Assembly.Load(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence securityEvidence)
   at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
   at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
   at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] 
...
System.InvalidOperationException: 
   at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
   at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
   at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
   at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
   at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
   at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
   at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
...

有什么提示吗?

我在这里找到了解决方案。。。

“当序列化设置设置为auto/on且您在项目中使用Web服务时,将在输出文件夹(例如SourceAssembly.XmlSerializers.dll)中自动生成序列化程序集,您需要在SQL中注册该程序集,如以下代码段所示:

CREATE ASSEMBLY CLRProcedures FROM 'C:\demos\CSTruter.com\CLRSQL\bin\Release\SourceAssembly.dll' 
WITH PERMISSION_SET = UNSAFE
GO
CREATE ASSEMBLY CLRSerializer FROM 'C:\demos\CSTruter.com\CLRSQL\bin\Release\SourceAssembly.XmlSerializers.dll' 
WITH PERMISSION_SET = UNSAFE
GO
CREATE PROCEDURE Test
AS EXTERNAL NAME [CLRProcedures].[CSTruter.com.StoredProcedures].[Test]"

虽然不希望无益,但错误消息相当具体,通过谷歌搜索,它给出了一些有关web服务和XML序列化的信息,这似乎与您的情况有关。您是否已经查看了这些信息(甚至有一篇Microsoft KB文章)如果是这样的话,你尝试过/学到了什么?这可能有助于避免人们发布你已经尝试过的建议。是的,我忘了在开场白中提到这一点。我虔诚地遵循了三个链接上的说明,然后回顾了我的步骤,并试图找到教程后面评论的提示。我还直接搜索了错误消息和我找到的所有帮助都指向没有在数据库上部署的序列化程序,但正如我所说的,它已部署,因为我可以在程序集文件夹中看到它,使用VS2010服务器资源管理器或SQL Server Management Studio。