Error : Cannot serialize member

H

Humair Ahmed

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.?
 
J

Jan Tielens

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 said:
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) +699System.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.?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,961
Messages
2,570,131
Members
46,689
Latest member
liammiller

Latest Threads

Top