Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Struggling with System.IO.Packaging when creating a CLR procedure

, 19 Oct 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
System.IO.Packaging namespace in WindowsBase may cause problems when trying to cerate a CLR procedure.

The problem

I started to create a small CLR procedure into Sql Server 2012 Express Edition which would utilize System.IO.Packaging namespace. In order to use this namespace, WindowsBase must be referenced. After adding the required reference everything seemed to be fine when compiling the assembly.

Now when trying to register the newly created assembly to Sql Server, I got an error message stating:

Msg 10301, Level 16, State 1, Line 1

Assembly 'Test' references assembly 'system.xaml, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request. 

Now, this was surprising, but understandable. So I added System.Xaml to the project references; After all I had no use for the visual interface in my project. 

After compiling the project I re-tried to register the assembly. This time I received a different error:

Warning: The Microsoft .NET Framework assembly 'system.xaml, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.' you are registering is not fully tested in the SQL Server hosted environment and is not supported. In the future, if you upgrade or service this assembly or the .NET Framework, your CLR integration routine may stop working. Please refer SQL Server Books Online for more details.

Msg 6218, Level 16, State 2, Line 1

CREATE ASSEMBLY for assembly 'Test' failed because assembly 'System.Xaml' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message
[ : System.Windows.Markup.ValueSerializer::CanConvertToString][mdToken=0x6000002][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::CanConvertFromString][mdToken=0x6000003][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::ConvertToString][mdToken=0x6000004][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::ConvertFromString][mdToken=0x6000005][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::TypeReferences][mdToken=0x6000006][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::.ctor][mdToken=0x6000001][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::.cctor][mdToken=0x600000d][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::GetSerializerFor][mdToken=0x6000007][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::GetSerializerFor][mdToken=0x6000008][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::GetSerializerFor][mdToken=0x6000009][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::GetSerializerFor][mdToken=0x600000a][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::GetConvertToException][mdToken=0x600000b][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.ValueSerializer::GetConvertFromException][mdToken=0x600000c][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.MemberDefinition::.ctor][mdToken=0x6000010][offset 0x00000000] Code size is zero.
[ : System.Windows.Markup.PropertyDefinition::get_Name][mdToken=0x6000011][offset 0x00000000] Code size is... 

So after all I wasn't able to register the assembly to Sql Server at all.

What about other versions

Well I tried the same with Sql Server 2008 R2 with no success. The error message was different and I needed to reference accessibility assembly which wasn't verified against Sql Server.
I also tried this with Sql Server 2005 and it was quite a big surprise that Sql Server 2005 seems to accept my assembly.

Conclusions 

So it looks like newer versions of Sql Server don't accept WindowsBase reference. While I do understand this since lot's of the classes in this assembly are used in creating an user interface I don't quite understand why some basic functionality such as System.IO.Packaging is included in the same assembly.
Another potential problem is the System.Security.RightsManagement namespace which is included in WindowsBase.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mika Wendelius
Architect
Finland Finland
I've been a programmer since mid 80's using languages like assembler, C/C++, PL/I (mainframe environment), pascal, VB (I know, I know, no comments please) and C# and utilizing different techniques and tools.
 
However I'm specialized in databases and database modeling. Mostly I have used products like Oracle (from version 6), SQL Server (from version 4.2), DB2 and Solid Server (nowadays an IBM product).
 
For the past 10+ years my main concerns have been dealing with different business processes and how to create software to implement and improve them. At my spare time (what ever that actually means) I'm also teaching and consulting on different areas of database management, development and database oriented software design.

Comments and Discussions

 
QuestionLocation of namespaces PinmemberMaciej Skierski11-Oct-12 17:54 
QuestionFailure to load is apparently be design PinmemberMaciej Skierski11-Oct-12 12:40 
AnswerRe: Failure to load is apparently be design PinmvpMika Wendelius11-Oct-12 17:39 
QuestionSurprised! PinmvpMehdi Gholam6-Oct-12 19:51 
AnswerRe: Surprised! PinmvpMika Wendelius7-Oct-12 2:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 19 Oct 2012
Article Copyright 2012 by Mika Wendelius
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid