DataTable is not serializable, you have to put them in a
dataset.

>-----Original Message-----
>Hey, here is my simple WebMethod. I'm passing a
DataTable object to it.
>
> [WebMethod()]
> public string TestMethod(DataTable dt)
> {
> return dt.ToString();
> }
>
>Quite to my surprise, ASP.NET spew out errors to me when
I visit the .asmx
>file.
>
>I just got no idea what these messages mean and why I
can't pass in a
>DataTable while I can pass in a DataSet.
>
>Help me!
>Server Error in '/MyWebApps/WebApplication1' Application.
>---------------------------------------------------------
-------------------
>----
>
>Cannot serialize member
System.ComponentModel.MarshalByValueComponent.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.MarshalByValueComponent.Sit e 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.MarshalByValueComponent.Sit e of
type
>System.ComponentModel.ISite because it is an interface.]
> System.Xml.Serialization.TypeScope.ImportTypeDesc
(Type type, Boolean
>canBePrimitive, MemberInfo memberInfo) +1283
> System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e
type, MemberInfo
>source, Boolean directReference) +50
> System.Xml.Serialization.StructModel.GetPropertyMo del
(PropertyInfo
>propertyInfo) +54
> System.Xml.Serialization.StructModel.GetFieldModel
(MemberInfo memberInfo)
>+88
>
>System.Xml.Serialization.XmlReflectionImporter.Im portStru
ctLikeMapping(Struc
>tModel model, String ns) +1534
>
>System.Xml.Serialization.XmlReflectionImporter.Im portStru
ctLikeMapping(Struc
>tModel model, String ns) +662
>
>System.Xml.Serialization.XmlReflectionImporter.Im portType
Mapping(TypeModel
>model, String ns, ImportContext context, String
dataType, Boolean repeats)
>+440
>
>[InvalidOperationException: There was an error
reflecting type
>'System.Data.DataTable'.]
>
>System.Xml.Serialization.XmlReflectionImporter.Im portType
Mapping(TypeModel
>model, String ns, ImportContext context, String
dataType, Boolean repeats)
>+1059
>
>System.Xml.Serialization.XmlReflectionImporter.Im portAcce
ssorMapping(MemberM
>apping accessor, FieldModel model, XmlAttributes a,
String ns, Type
>choiceIdentifierType) +8238
>
>System.Xml.Serialization.XmlReflectionImporter.Im portMemb
erMapping(XmlReflec
>tionMember xmlReflectionMember, String ns,
XmlReflectionMember[]
>xmlReflectionMembers) +795
>
>System.Xml.Serialization.XmlReflectionImporter.Im portMemb
ersMapping(XmlRefle
>ctionMember[] xmlReflectionMembers, String ns, Boolean
hasWrapperElement)
>+300
>
>[InvalidOperationException: There was an error
reflecting 'dt'.]
>
>System.Xml.Serialization.XmlReflectionImporter.Im portMemb
ersMapping(XmlRefle
>ctionMember[] xmlReflectionMembers, String ns, Boolean
hasWrapperElement)
>+607
>
>System.Xml.Serialization.XmlReflectionImporter.Im portMemb
ersMapping(String
>elementName, String ns, XmlReflectionMember[] members,
Boolean
>hasWrapperElement) +108
>
>System.Web.Services.Protocols.SoapReflector.Impor tMembers
Mapping(XmlReflecti
>onImporter xmlImporter, SoapReflectionImporter
soapImporter, Boolean
>serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse
use, SoapParameterStyle
>paramStyle, String elementName, String elementNamespace,
Boolean
>nsIsDefault, XmlReflectionMember[] members, Boolean
validate) +169
>
>System.Web.Services.Protocols.SoapReflector.Refle ctMethod
(LogicalMethodInfo
>methodInfo, Boolean client, XmlReflectionImporter
xmlImporter,
>SoapReflectionImporter soapImporter, String defaultNs)
+1915
>
>[InvalidOperationException: Method Service1.TestMethod2
can not be
>reflected.]
>
>System.Web.Services.Protocols.SoapReflector.Refle ctMethod
(LogicalMethodInfo
>methodInfo, Boolean client, XmlReflectionImporter
xmlImporter,
>SoapReflectionImporter soapImporter, String defaultNs)
+5415
>
System.Web.Services.Description.SoapProtocolReflec tor.Refl
ectMethod()
>+130
>
>System.Web.Services.Description.ProtocolReflector .Reflect
Binding(ReflectedBi
>nding reflectedBinding) +1818
>
System.Web.Services.Description.ProtocolReflector. Reflect
() +506
>
>System.Web.Services.Description.ServiceDescriptio nReflect
or.ReflectInternal(
>ProtocolReflector[] reflectors) +495
>
System.Web.Services.Description.ServiceDescription Reflecto
r.Reflect(Type
>type, String url) +112
>
System.Web.Services.Protocols.DocumentationServerT ype..cto
r(Type type,
>String uri) +158
>
System.Web.Services.Protocols.DocumentationServerP rotocol.
Initialize()
>+268
>
System.Web.Services.Protocols.ServerProtocolFactor y.Create
(Type type,
>HttpContext context, HttpRequest request, HttpResponse
response, Boolean&
>abortProcessing) +106
>
>[InvalidOperationException: Unable to handle request.]
>
System.Web.Services.Protocols.ServerProtocolFactor y.Create
(Type type,
>HttpContext context, HttpRequest request, HttpResponse
response, Boolean&
>abortProcessing) +205
>
>System.Web.Services.Protocols.WebServiceHandlerFa ctory.Co
reGetHandler(Type
>type, HttpContext context, HttpRequest request,
HttpResponse response) +82
>
>[InvalidOperationException: Failed to handle request.]
>
>System.Web.Services.Protocols.WebServiceHandlerFa ctory.Co
reGetHandler(Type
>type, HttpContext context, HttpRequest request,
HttpResponse response) +154
>
>System.Web.Services.Protocols.WebServiceHandlerFa ctory.Ge
tHandler(HttpContex
>t context, String verb, String url, String filePath) +94
> System.Web.HttpApplication.MapHttpHandler(HttpCont ext
context, String
>requestType, String path, String pathTranslated, Boolean
useAppConfig) +699
>
>System.Web.MapHandlerExecutionStep.System.Web.Htt pApplica
tion+IExecutionStep
>..Execute() +95
> System.Web.HttpApplication.ExecuteStep(IExecutionS tep
step, Boolean&
>completedSynchronously) +173
>
>
>
>
>
>---------------------------------------------------------
-------------------
>----
>
>Version Information: Microsoft .NET Framework
Version:1.1.4322.573; ASP.NET
>Version:1.1.4322.573
>
>
>.
>