Error : Cannot serialize member

Discussion in 'ASP .Net Web Services' started by Humair Ahmed, Apr 26, 2004.

  1. Humair Ahmed

    Humair Ahmed Guest

    Server Error in '/IISManage' Application.
    ----------------------------------------------------------------------------
    ----

    Cannot serialize member System.ComponentModel.Component.Site of type
    System.ComponentModel.ISite because it is an interface.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.NotSupportedException: Cannot serialize member
    System.ComponentModel.Component.Site of type System.ComponentModel.ISite
    because it is an interface.

    Source Error:

    An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of the
    exception can be identified using the exception stack trace below.

    Stack Trace:

    [NotSupportedException: Cannot serialize member
    System.ComponentModel.Component.Site of type System.ComponentModel.ISite
    because it is an interface.]
    System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, Boolean
    canBePrimitive, MemberInfo memberInfo)
    System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo
    source, Boolean directReference)
    System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo
    source)
    System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo
    propertyInfo)
    System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo)

    System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(Struc
    tModel model, String ns)

    System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(Struc
    tModel model, String ns)

    System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel
    model, String ns, ImportContext context, String dataType, Boolean repeats)

    [InvalidOperationException: There was an error reflecting type
    'System.DirectoryServices.DirectoryEntry'.]

    System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel
    model, String ns, ImportContext context, String dataType, Boolean repeats)

    System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel
    model, String ns, ImportContext context, String dataType)

    System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberM
    apping accessor, FieldModel model, XmlAttributes a, String ns, Type
    choiceIdentifierType)

    System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflec
    tionMember xmlReflectionMember, String ns, XmlReflectionMember[]
    xmlReflectionMembers)

    System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlRefle
    ctionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)

    [InvalidOperationException: There was an error reflecting 'objObject'.]

    System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlRefle
    ctionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)

    System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String
    elementName, String ns, XmlReflectionMember[] members, Boolean
    hasWrapperElement)

    System.Web.Services.Protocols.SoapReflector.ImportMembersMapping(XmlReflecti
    onImporter xmlImporter, SoapReflectionImporter soapImporter, Boolean
    serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle
    paramStyle, String elementName, String elementNamespace, Boolean
    nsIsDefault, XmlReflectionMember[] members, Boolean validate)

    System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo
    methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
    SoapReflectionImporter soapImporter, String defaultNs)

    [InvalidOperationException: Method Service1.displayshildren can not be
    reflected.]

    System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo
    methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
    SoapReflectionImporter soapImporter, String defaultNs)
    System.Web.Services.Description.SoapProtocolReflector.ReflectMethod()

    System.Web.Services.Description.ProtocolReflector.ReflectBinding(ReflectedBi
    nding reflectedBinding)
    System.Web.Services.Description.ProtocolReflector.Reflect()

    System.Web.Services.Description.ServiceDescriptionReflector.ReflectInternal(
    ProtocolReflector[] reflectors)
    System.Web.Services.Description.ServiceDescriptionReflector.Reflect(Type
    type, String url)
    System.Web.Services.Protocols.DocumentationServerType..ctor(Type type,
    String uri)
    System.Web.Services.Protocols.DocumentationServerProtocol.Initialize()
    System.Web.Services.Protocols.ServerProtocol.SetContext(Type type,
    HttpContext context, HttpRequest request, HttpResponse response)
    System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,
    HttpContext context, HttpRequest request, HttpResponse response, Boolean&
    abortProcessing)

    [InvalidOperationException: Unable to handle request.]
    System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,
    HttpContext context, HttpRequest request, HttpResponse response, Boolean&
    abortProcessing)

    System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type
    type, HttpContext context, HttpRequest request, HttpResponse response)

    [InvalidOperationException: Failed to handle request.]

    System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type
    type, HttpContext context, HttpRequest request, HttpResponse response)

    System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContex
    t context, String verb, String url, String filePath)
    System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
    requestType, String path, String pathTranslated, Boolean useAppConfig) +699

    System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep
    ..Execute() +95
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    completedSynchronously) +173



    We encounter that problem when i am running my service with this code



    Imports System.Web.Services

    <System.Web.Services.WebService(Namespace :=
    "http://tempuri.org/IISManage/Service1")> _

    Public Class Service1

    ' WEB SERVICE EXAMPLE

    ' The HelloWorld() example service returns the string Hello World.

    ' To build, uncomment the following lines then save and build the project.

    ' To test this web service, ensure that the .asmx file is the start page

    ' and press F5.

    '

    '<WebMethod()> _

    'Public Function HelloWorld() As String

    ' Return "Hello World"

    'End Function

    <WebMethod()> _

    Public Sub displayshildren(ByVal objObject As
    DirectoryServices.DirectoryEntry, ByVal strSpaces As String)

    Console.WriteLine(strSpaces & objObject.Name)

    Dim objChild As DirectoryServices.DirectoryEntry

    For Each objChild In objObject.Children

    displayshildren(objChild, strSpaces & " ")

    Next

    End Sub

    <WebMethod()> _

    Public Function returnSite(ByVal objObject As
    System.DirectoryServices.DirectoryEntry) As String

    'Dim SiteArr(0) As String

    Dim SiteArr As String

    Dim objChild As DirectoryServices.DirectoryEntry

    For Each objChild In objObject.Children

    SiteArr = objChild.Name

    Next

    Return SiteArr

    End Function

    End Class



    --Can any one give me a solution to that.?
    Humair Ahmed, Apr 26, 2004
    #1
    1. Advertising

  2. Humair Ahmed

    Jan Tielens Guest

    Probably have a return value or parameter of the Site type. This class
    cannot be serialized so it can not be used as a return value of parameter of
    a web service.

    --
    Greetz,
    Jan
    ________________________
    Read my weblog: http://weblogs.asp.net/jan

    "Humair Ahmed" <> schreef in bericht
    news:%...
    >
    > Server Error in '/IISManage' Application.
    > --------------------------------------------------------------------------

    --
    > ----
    >
    > Cannot serialize member System.ComponentModel.Component.Site of type
    > System.ComponentModel.ISite because it is an interface.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.NotSupportedException: Cannot serialize member
    > System.ComponentModel.Component.Site of type System.ComponentModel.ISite
    > because it is an interface.
    >
    > Source Error:
    >
    > An unhandled exception was generated during the execution of the
    > current web request. Information regarding the origin and location of the
    > exception can be identified using the exception stack trace below.
    >
    > Stack Trace:
    >
    > [NotSupportedException: Cannot serialize member
    > System.ComponentModel.Component.Site of type System.ComponentModel.ISite
    > because it is an interface.]
    > System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, Boolean
    > canBePrimitive, MemberInfo memberInfo)
    > System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo
    > source, Boolean directReference)
    > System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo
    > source)
    > System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo
    > propertyInfo)
    > System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo

    memberInfo)
    >
    >

    System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(Struc
    > tModel model, String ns)
    >
    >

    System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(Struc
    > tModel model, String ns)
    >
    > System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel
    > model, String ns, ImportContext context, String dataType, Boolean repeats)
    >
    > [InvalidOperationException: There was an error reflecting type
    > 'System.DirectoryServices.DirectoryEntry'.]
    >
    > System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel
    > model, String ns, ImportContext context, String dataType, Boolean repeats)
    >
    > System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel
    > model, String ns, ImportContext context, String dataType)
    >
    >

    System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberM
    > apping accessor, FieldModel model, XmlAttributes a, String ns, Type
    > choiceIdentifierType)
    >
    >

    System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflec
    > tionMember xmlReflectionMember, String ns, XmlReflectionMember[]
    > xmlReflectionMembers)
    >
    >

    System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlRefle
    > ctionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)
    >
    > [InvalidOperationException: There was an error reflecting 'objObject'.]
    >
    >

    System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlRefle
    > ctionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)
    >
    > System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String
    > elementName, String ns, XmlReflectionMember[] members, Boolean
    > hasWrapperElement)
    >
    >

    System.Web.Services.Protocols.SoapReflector.ImportMembersMapping(XmlReflecti
    > onImporter xmlImporter, SoapReflectionImporter soapImporter, Boolean
    > serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use,

    SoapParameterStyle
    > paramStyle, String elementName, String elementNamespace, Boolean
    > nsIsDefault, XmlReflectionMember[] members, Boolean validate)
    >
    >

    System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo
    > methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
    > SoapReflectionImporter soapImporter, String defaultNs)
    >
    > [InvalidOperationException: Method Service1.displayshildren can not be
    > reflected.]
    >
    >

    System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo
    > methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
    > SoapReflectionImporter soapImporter, String defaultNs)
    > System.Web.Services.Description.SoapProtocolReflector.ReflectMethod()
    >
    >

    System.Web.Services.Description.ProtocolReflector.ReflectBinding(ReflectedBi
    > nding reflectedBinding)
    > System.Web.Services.Description.ProtocolReflector.Reflect()
    >
    >

    System.Web.Services.Description.ServiceDescriptionReflector.ReflectInternal(
    > ProtocolReflector[] reflectors)
    >

    System.Web.Services.Description.ServiceDescriptionReflector.Reflect(Type
    > type, String url)
    > System.Web.Services.Protocols.DocumentationServerType..ctor(Type type,
    > String uri)
    > System.Web.Services.Protocols.DocumentationServerProtocol.Initialize()
    > System.Web.Services.Protocols.ServerProtocol.SetContext(Type type,
    > HttpContext context, HttpRequest request, HttpResponse response)
    > System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,
    > HttpContext context, HttpRequest request, HttpResponse response, Boolean&
    > abortProcessing)
    >
    > [InvalidOperationException: Unable to handle request.]
    > System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,
    > HttpContext context, HttpRequest request, HttpResponse response, Boolean&
    > abortProcessing)
    >
    > System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type
    > type, HttpContext context, HttpRequest request, HttpResponse response)
    >
    > [InvalidOperationException: Failed to handle request.]
    >
    > System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type
    > type, HttpContext context, HttpRequest request, HttpResponse response)
    >
    >

    System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContex
    > t context, String verb, String url, String filePath)
    > System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
    > requestType, String path, String pathTranslated, Boolean useAppConfig)

    +699
    >
    >

    System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep
    > .Execute() +95
    > System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    > completedSynchronously) +173
    >
    >
    >
    > We encounter that problem when i am running my service with this code
    >
    >
    >
    > Imports System.Web.Services
    >
    > <System.Web.Services.WebService(Namespace :=
    > "http://tempuri.org/IISManage/Service1")> _
    >
    > Public Class Service1
    >
    > ' WEB SERVICE EXAMPLE
    >
    > ' The HelloWorld() example service returns the string Hello World.
    >
    > ' To build, uncomment the following lines then save and build the project.
    >
    > ' To test this web service, ensure that the .asmx file is the start page
    >
    > ' and press F5.
    >
    > '
    >
    > '<WebMethod()> _
    >
    > 'Public Function HelloWorld() As String
    >
    > ' Return "Hello World"
    >
    > 'End Function
    >
    > <WebMethod()> _
    >
    > Public Sub displayshildren(ByVal objObject As
    > DirectoryServices.DirectoryEntry, ByVal strSpaces As String)
    >
    > Console.WriteLine(strSpaces & objObject.Name)
    >
    > Dim objChild As DirectoryServices.DirectoryEntry
    >
    > For Each objChild In objObject.Children
    >
    > displayshildren(objChild, strSpaces & " ")
    >
    > Next
    >
    > End Sub
    >
    > <WebMethod()> _
    >
    > Public Function returnSite(ByVal objObject As
    > System.DirectoryServices.DirectoryEntry) As String
    >
    > 'Dim SiteArr(0) As String
    >
    > Dim SiteArr As String
    >
    > Dim objChild As DirectoryServices.DirectoryEntry
    >
    > For Each objChild In objObject.Children
    >
    > SiteArr = objChild.Name
    >
    > Next
    >
    > Return SiteArr
    >
    > End Function
    >
    > End Class
    >
    >
    >
    > --Can any one give me a solution to that.?
    >
    >
    Jan Tielens, Apr 26, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gordz
    Replies:
    3
    Views:
    3,922
    John Oakes
    Jun 7, 2004
  2. Maurice LING
    Replies:
    0
    Views:
    272
    Maurice LING
    Dec 8, 2005
  3. Jean-Paul Calderone
    Replies:
    1
    Views:
    357
    Maurice LING
    Dec 8, 2005
  4. Jean-Paul Calderone
    Replies:
    2
    Views:
    534
    Fredrik Lundh
    Dec 9, 2005
  5. john harkin
    Replies:
    1
    Views:
    750
    john harkin
    Sep 23, 2004
Loading...

Share This Page