I know this question has been asked before, but none of the answers I've tried seem to work for me.

I'm trying to execute a CLR Stored Procedure in Sql Server 2005. The CLR generates a file, sends it to a webservice, reads the XML response (using .net's XML serialization classes) and logs the result.

When I try to execute it, I get this error:

System.InvalidOperationException: Cannot load dynamically generated serialization assembly. In some hosting environments assembly load functionality is restricted, consider using pre-generated serializer.

Supposedly, this can be fixed by using the XML Serializer Generator tool (Sgen.exe) to create the XML serialization assembly for the original assembly manually and then loading the assemblies into the SQL Server database. (See here, here and here)

I've generated the XML Serialization assembly, loaded into the database, and decorated the serialization classes using the XmlSerializerAssembly attribute. Still get the same error.

I've tried using different versions of the sgen.exe tool and toyed with different permission sets for the assemblies, to no avail.

What am I missing? Is there some configuration in the server that can prevent this from working?

  • In your research, did you also read the countless warnings to not use SQLCLR to connect to webservices? – Remus Rusanu Nov 28 '13 at 14:32
  • @RemusRusanu yes, I did. Unfortunately, using the clr to connect to the webservice is not really my call to make. I'd still like to make this work. – jlasarte Nov 28 '13 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.