A serialized assembly will not load into the database

I have a CLR project that calls a simple HTTP service. Its x64 targeting, and I got it for proper serialization only by going through the steps described in the following link, which talks about the changes needed for VS2010 to point to the correct target architecture (x64) - changes that are only needed for unloading and changes. csproj with a few extra lines to link to the correct version of sgen.exe: http://geekswithblogs.net/akraus1/archive/2011/12/10/148002.aspx

Now I can create this project and its .XmlSerializers.dll by setting "Generate Serialized Assembly" to. I want to do this because my CLR project will be deployed in the database, and I do not want it to start serializing any objects, since these DLLs are not referenced in my database, and I do not want to grant my rights to the CLR project above. than EXTERNAL_ACCESS for security reasons, because it will be used in a production environment where security is important, and also because my database is NOT trustworthy.

In short, I follow the guide at the following link to load my serialized assembly into the database, but I get an error message: http://footheory.com/blogs/bennie/archive/2006/12/07/invoking-a- web-service-from-a-sqlclr-stored-procedure.aspx

Error: CREATE ASSEMBLY for assembly '.XmlSerializers' failed because the assembly was built for an unsupported version of the Common Language Runtime.

Does anyone know how to fix this by causing sgen.exe to serialize a build version that supports the CLR? Viva the Stack.

+4
source share
2 answers

I found that the problem is not really that I am using .NET 3.5 as the target, but I was referring to the wrong version of the sgen.exe tool, which in this case I need x64 version 6.0 A (which translates to .NET 3.5 ) along this path: C: \ Program Files \ Microsoft SDK \ Windows \ v6.0A \ Bin \ x64 \ sgen.exe. Now I can build the correct version of the serialization assembly, download it, and use it.

+2
source

SQL Server 2005/2008 / 2008R2 only supports .Net 2.0. You need to modify your project to configure it, see How to configure a specific version or profile of the .NET Framework . You do not need to specify x64 for the purpose of the assembly, the SQLCLR assemblies must be combined for a common purpose.

Nevertheless, the call Web services from SQLCLR - it really is a really bad idea. Do not do that. Have an external process to handle HTTP calls.

+2
source

All Articles