0

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.

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user484458
  • 168
  • 3
  • 11

1 Answers1

1

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

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.

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:

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

More details about sgen are available here.

Michael Petito
  • 12,891
  • 4
  • 40
  • 54
  • first of thank you very much for your support. Yes i'm using a WCF But even after creating xmlserializer.dll file and registering it in SQL server, same error is coming. – user484458 Mar 16 '15 at 20:13
  • So you have `SomeAssembly.dll` and `SomeAssembly.XmlSerializers.dll` loaded? If so, it seems your WCF contract may involve types from other assemblies for which you'll also need to generate a serialization assembly. – Michael Petito Mar 17 '15 at 18:23