none
System.Data.Linq.Binary erro na serialização RRS feed

  • Pergunta

  • Olá pessoal!

    Estou com um problema quando tento rodar meu webservice

    Acredito que o erro seja no serializar o campo image do BD alguém tem uma solução para esse problema?

    Estou usando LINQ, e SQLServer

    segue o codigo, a tabela e o erro:

     

    [WebMethod(Description="Retorna todos os registros cadastrados")]

     

            public List<IMAGE> getAll()

            {

                List<IMAGE> imagens = new List<IMAGE>();

                using (BDDataContext bd = new BDDataContext())

                {

                   imagens = (from p in bd.IMAGEs

                              select p).ToList<IMAGE>();

                }

                return imagens;

            }

     

     

    a tabela do BD mapeada tem o nome de "IMAGE" e contem os seguintes campos:

    id - int

    imageData - Image

    name - varchar

    description - varchar

     

    O erro que surge é este:

     

    System.Data.Linq.Binary não pode ser serializado porque não tem um construtor sem parâmetros.

    [InvalidOperationException: System.Data.Linq.Binary não pode ser serializado porque não tem um construtor sem parâmetros.]
    
    [InvalidOperationException: Não é possível serializar o membro 'TCC_SERVICE.Model.IMAGE.imageData' do tipo 'System.Data.Linq.Binary'. Consulte a exceção interna para obter mais detalhes.]
      System.Xml.Serialization.StructModel.CheckSupportedMember(TypeDesc typeDesc, MemberInfo member, Type type) +891213
      System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo propertyInfo) +132
      System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo) +129
      System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter) +1226
      System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter) +460
      System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter) +1415
    
    [InvalidOperationException: Erro ao refletir tipo 'TCC_SERVICE.Model.IMAGE'.]
      System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter) +1621
      System.Xml.Serialization.XmlReflectionImporter.CreateArrayElementsFromAttributes(ArrayMapping arrayMapping, XmlArrayItemAttributes attributes, Type arrayElementType, String arrayElementNs, RecursionLimiter limiter) +227
      System.Xml.Serialization.XmlReflectionImporter.ImportArrayLikeMapping(ArrayModel model, String ns, RecursionLimiter limiter) +207
      System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +6265
      System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +722
      System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +236
    
    [InvalidOperationException: Erro ao refletir 'getAllResult'.]
      System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +843
      System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access) +130
      System.Web.Services.Protocols.SoapReflector.ImportMembersMapping(XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, Boolean serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault, XmlReflectionMember[] members, Boolean validate, Boolean openModel, String key, Boolean writeAccess) +223
      System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs) +2989
    
    [InvalidOperationException: O método Service1.getAll não pode ser refletido.]
      System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs) +6527
      System.Web.Services.Description.SoapProtocolReflector.ReflectMethod() +91
      System.Web.Services.Description.ProtocolReflector.ReflectBinding(ReflectedBinding reflectedBinding) +1798
      System.Web.Services.Description.ProtocolReflector.Reflect() +703
      System.Web.Services.Description.ServiceDescriptionReflector.ReflectInternal(ProtocolReflector[] reflectors) +394
      System.Web.Services.Description.ServiceDescriptionReflector.Reflect(Type type, String url) +109
      System.Web.Services.Protocols.DocumentationServerType..ctor(Type type, String uri) +156
      System.Web.Services.Protocols.DocumentationServerProtocol.Initialize() +284
      System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) +50
      System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) +77
    
    [InvalidOperationException: Não é possível lidar com a solicitação.]
      System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) +285
      System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +183
    
    [InvalidOperationException: Falha ao manipular a solicitação.]
      System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +354
      System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212
      System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
      System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +193
      System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
      System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

     

     

    quinta-feira, 6 de maio de 2010 12:22

Respostas