none
Using XLinq on SQL Server 2005 - Method not found RRS feed

  • Question

  • Hey,

     

    i wanted to use XLinq in a clr function on the SQL 2005 Server. I had to register the System.Core.dll and System.XML.Linq.dll to deploy the function. Then i tried to start the function. There i did get this error message:

     

    Msg 6522, Level 16, State 1, Line 2

    A .NET Framework error occurred during execution of user-defined routine or aggregate "test":

    System.MissingMethodException: Method not found: 'Void System.Xml.XmlReaderSettings.set_MaxCharactersFromEntities(Int64)'.

    System.MissingMethodException:

    at System.Xml.Linq.XNode.GetXmlReaderSettings(LoadOptions o)

    at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)

    at StoredProcedures.test()

     

    I thought i also had to register the System.XML.dll on the server but it was already there.

     

    "System.MissingMethodException: Method not found: 'Void System.Xml.XmlReaderSettings.set_MaxCharactersFromEntities(Int64)'."

    This function is part of the System.XML.dll from 2.xx framework.

     

    My Project is created and compiled with VS 2008 and the Framework 3.5.

     

    Here a little test-function which shows the error:

    [Microsoft.SqlServer.Server.SqlFunction(SystemDataAccess = SystemDataAccessKind.Read)]

    public static SqlString test()

    {

    using (SqlConnection conn = new SqlConnection("context connection = true"))

    {

    string temp = "";

    XDocument doc = XDocument.Load("\\\\cmhmd23019\\test\\UNIT_472901S0003602_20080703122622.xml");

    var schemaname_temp =

    from element in doc.Elements("Schema").Attributes("name")

    select new { element.Value };

    foreach (var a in schemaname_temp)

    {

    temp = a.Value;

    }

    SqlString temp2 = temp;

    return temp2;

    }

    }

     

    Any Suggestions?

     

    Greets Kamei

    Thursday, July 24, 2008 11:12 AM

Answers

  • I created the dlls from the 3.5 framework without error on the Server. Now we decided to install the whole 3.5 framework on the server. I dropped the assemblies i created myself on the server. And then i manually created the assemblies from the 3.5 framework on the server. After this all worked fine.

    The problem was that the server runs on 64 bit and my local machine is on 32 bit. So i had to create the 64 bit .dlls directly on the server.

     

    Maybe this helps anyone else with the same problem...

     

    Regards Kamei

    Friday, July 25, 2008 1:30 PM

All replies

  • Hi Kamei,

    SQL Server 2005 only runs the .Net Framework 2.0 by default, no matter under what framework you compiled your assembly.

    You have to manually reference the 3.5 assemblies : http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2639225&SiteID=17.

    Marc

    Thursday, July 24, 2008 2:15 PM
  • I created the dlls from the 3.5 framework without error on the Server. Now we decided to install the whole 3.5 framework on the server. I dropped the assemblies i created myself on the server. And then i manually created the assemblies from the 3.5 framework on the server. After this all worked fine.

    The problem was that the server runs on 64 bit and my local machine is on 32 bit. So i had to create the 64 bit .dlls directly on the server.

     

    Maybe this helps anyone else with the same problem...

     

    Regards Kamei

    Friday, July 25, 2008 1:30 PM