Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
SQL Server has supported CLR usage since version 2005. But support of .NET framework assemblies within SQL Server is limited per our support policy in KB https://support.microsoft.com/kb/922672.
Some users chose to use .NET framework assemblies outside the list in KB https://support.microsoft.com/kb/922672. This can cause various issues. Lately we have had a few reports of the following error following upgrade to SQL Server 2012.
Msg 6544, Level 16, State 1, Line 2
CREATE ASSEMBLY for assembly '<assembly name>' failed because assembly ‘<assembly name>’ is malformed or not a pure .NET assembly. Unverifiable PE Header/native stub.
A little background. When you develop your user assembly, you can reference .NET framework assemblies. If the referenced .NET framework assemblies are all from the supported list, you only need to register your own user assembly by using CREATE ASSEMBLY statement. When you use a .NET framework assembly that is not in the supported list, the following happens:
There are two types of .NET assemblies. Pure .NET assemblies only contain MSIL instructions. Mixed assemblies contain both unmanaged machine instructions and MSIL instructions. Mixed assemblies in general are compiled by C++ compiler with /clr switch but contain machine instructions resulting from native C++ code.
Regardless which version of SQL Server, CREATE ASSEMBLY only allows pure .NET assemblies to be registered. SQL Server has always required that an assembly to be loaded into SQL Server database with CREATE ASSEMBLY contains only MSIL instructions (pure assembly). CREATE ASSEMBLY will raise the above error if an assembly to be registered is mixed assembly.
Why are we seeing this issue now more often than before?
SQL Server 2005, 2008 and 2008 R2 use CLR 2.0. In SQL Server 2012, we upgraded CLR to use 4.0. As a result, all the .NET framework assemblies will need to be in version 4.0. If you have used a .NET framework assembly that is not in the supported list, you must re-register the 4.0 version using CREATE ASSEMBLY statement following upgrade. Some .NET framework assembly such as WCF started referencing mixed mode assembly in 4.0. Therefore you started to experience the issue in SQL 2012 instead of early versions.
A couple of clarifications
Jack Li | Senior Escalation Engineer | Microsoft SQL Server Support
Anonymous
July 23, 2013
Does sql 2012 supoprt microsoft.visualbasic.activities.compiler.dll ?
Anonymous
September 24, 2013
Yes,
Can you provide an answer to lana? We are trying use CLR to talk to a WCF service. In order to do that many references need to be added, one being microsoft.visualbasic.activities.compiler.dll.
Apparently you can't register this one. How is this supposed to work.
Framework 4.0/SQL Server 2012
Anonymous
October 31, 2013
The comment has been removed
Anonymous
July 23, 2014
Hi,
I have tried on our MS SQl Server 2012
CREATE ASSEMBLY pt_sap_rfc from 'F:CLR2012TestversionenNet40x64pt_sap_rfc.dll' WITH PERMISSION_SET = UNSAFE
and get this message:
"CREATE ASSEMBLY for assembly 'pt_sap_rfc' failed because assembly 'sapnco_utils' is malformed or not a pure .NET assembly.
Nicht überprüfbarer PE-Header / systemeigener Stub."
According to your point 2) I then tried
CREATE ASSEMBLY sapnco_utils from 'F:CLR2012TestversionenNet40x64sapnco_utils.dll' WITH PERMISSION_SET = UNSAFE
but instead of the warning (The Microsoft .Net frameworks assembly 'AssemblyName' you are registering is not fully tested in SQL Server hosted environment.)
I get the same message:
"CREATE ASSEMBLY for assembly 'sapnco_utils' failed because assembly 'sapnco_utils' is malformed or not a pure .NET assembly.
Nicht überprüfbarer PE-Header / systemeigener Stub."
Is there another switch or Flag that I have to set?
Thank you
Anonymous
May 12, 2016
The comment has been removed
Anonymous
August 23, 2016
Byline: James J.nike lunarglide womens http://womensnikepegasus.1max90.com/
Anonymous
October 20, 2016
Finally, some good clear documentation from Microsoft.
Please sign in to use this experience.
Sign in