Error creating a DLINQ Web Service

Hello all,

I've tried making a simple web service (asmx) to act as a front end to return DLINQ objects created from SqlMetal. However, when I run a method in the service that returns a DLINQ object, I get the error below. Is it supposed to be possible to do this or is this an unsupported action I have taken the exact same code and put it in a DLINQ console application instead of a DLINQ web application and it has worked fine. Also, I did choose the "DLINQ Web Application" as my project template and the web.config has been modified to use the new c# 3.0 compiler. Can anyone help me with this Has anyone had any luck with it yet

System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: key is wrong size
  at System.Data.DLinq.CommonDataServices.CreateKey(MetaType type, Object[] keyValues)
  at System.Data.DLinq.ProviderBase.DeferredSourceReader`1.QueryableLink.BuildQuery()
  at System.Data.DLinq.ProviderBase.DeferredSourceReader`1.QueryableLink.GetEnumerator()
  at System.Query.Sequence.SingleOrDefault[T](IEnumerable`1 source)
  at System.Data.DLinq.EntityRef`1.get_Entity()
  at MyApp.BaseCatalogHierarchy.get_BaseCatalogHP() in c:\Program Files\LINQ Preview\Samples\C#\Web\App_Code\MyAppCode.cs:line 1323
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_BaseCatalogHierarchy(String n, String ns, BaseCatalogHierarchy o, Boolean isNullable, Boolean needType)
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write5_BaseCatalogProduct(String n, String ns, BaseCatalogProduct o, Boolean isNullable, Boolean needType)
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write6_BaseCatalogProduct(Object o)
  at Microsoft.Xml.Serialization.GeneratedAssembly.BaseCatalogProductSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
  at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
  at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o)
  at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue)
  at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
  at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
  at System.Web.Services.Protocols.WebServiceHandler.Invoke()


Answer this question

Error creating a DLINQ Web Service

  • clecke

    Hi all,

    That error cause by passed dbnull value as paramerter's value in function call via webservice.
    I can not find any solution to pass dbnull value as paramater value. So any one help me


  • Error creating a DLINQ Web Service