无法执行在SQLCLR中创建的存储过程

时间:2022-09-20 23:47:47

I have create a stored procedure in SQLCLR (SQL Server Database Project, VS2012). I publish the stored procedure successfully to the database. But when I run the stored procedure in the database, I get an error.

我在SQLCLR(SQL Server数据库项目,VS2012)中创建了一个存储过程。我成功地将存储过程发布到数据库。但是当我在数据库中运行存储过程时,我收到错误。

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.

无法加载动态生成的序列化程序集。在某些托管环境中,组件加载功能受到限制,请考虑使用预生成的序列化程序。有关更多信息,请参阅内部异常。

Note: after publishing, no xmlserializer.dll is created. Even generate serialization assembly is set to ON.

注意:发布后,不会创建xmlserializer.dll。甚至生成序列化程序集也设置为ON。

1 个解决方案

#1


1  

Are you using WCF within your SQLCLR assembly (or some other web services client)?

您是否在SQLCLR程序集(或其他一些Web服务客户端)中使用WCF?

If so, you need to use the XML Serializer Generator tool to create the serialization assembly manually and then add it to SQL Server along with your original assembly.

如果是这样,您需要使用XML Serializer Generator工具手动创建序列化程序集,然后将其与原始程序集一起添加到SQL Server。

There are more detailed instructions at the above link, but the command you'll need (which can be added as a post-build step for your project) is something along the lines of:

上面的链接中有更详细的说明,但您需要的命令(可以作为项目的后期构建步骤添加)有以下几点:

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe" /force "$(TargetPath)"

Then in SQL Server:

然后在SQL Server中:

CREATE ASSEMBLY [(ProjectName).XmlSerializers.dll] from '(ProjectName).XmlSerializers.dll'

More details about sgen are available here.

有关sgen的更多详细信息,请点击此处。

#1


1  

Are you using WCF within your SQLCLR assembly (or some other web services client)?

您是否在SQLCLR程序集(或其他一些Web服务客户端)中使用WCF?

If so, you need to use the XML Serializer Generator tool to create the serialization assembly manually and then add it to SQL Server along with your original assembly.

如果是这样,您需要使用XML Serializer Generator工具手动创建序列化程序集,然后将其与原始程序集一起添加到SQL Server。

There are more detailed instructions at the above link, but the command you'll need (which can be added as a post-build step for your project) is something along the lines of:

上面的链接中有更详细的说明,但您需要的命令(可以作为项目的后期构建步骤添加)有以下几点:

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe" /force "$(TargetPath)"

Then in SQL Server:

然后在SQL Server中:

CREATE ASSEMBLY [(ProjectName).XmlSerializers.dll] from '(ProjectName).XmlSerializers.dll'

More details about sgen are available here.

有关sgen的更多详细信息,请点击此处。