Cannot serialize member System.ComponentModel.Component.Site of ty

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, i have developed a webservice , which has 2 methods one returns a
sqlconnection and the other one returns a dataset. if a add an aspx page in
that webservice project , the page gets the connection from the web method
well.But if i run the webservice alone(by making the websevice as a start up)
it gives the error like
 
Raghu,

You shouldn't be passing database connections back from web services.
Your web service is connected to by clients outside of your application
domain, and database connections aren't valid in those contexts (most
likely). If you are passing back a connection string, that is a different
story (but not that much better).

The reason this happens is that the Site property of the class returns
an interface. The XmlSerializer (which is used by web services to return
information about classes) doesn't know how to serialize this (because it
serializes public fields/properties, instead of the internal fields, and
that's it).

Hope this helps.
 
Back
Top