The following exception message is indicating that you're trying to return some object which is not serializable by the service runtime:
"Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface. "
and based on my test, if we simply return the string (by calling ToString on Connection object) in webservice webmethod, it should works correctly (here is the test webmethod I use):
[WebMethod]
public string GetConnectionString()
{
var sqlconn = new SqlConnection(@"data source=.\SQLExpress;initial catalog=Northwind;integrated security=True;");
return sqlconn.ToString();
}
Therefore, I'd suggest you recreating a webservice and define a similar webmethod to test it again. Also, you can verify if there is some other webmethods in your service which has directly return the SqlConnection object(that might cause the exception you
pasted above).
Steven Cheng...
Contributor
4199 Points
548 Posts
Microsoft
Moderator
Re: Created Web Services for Database connection and in Application!!!!
May 01, 2012 04:02 AM|LINK
Hi gopal_74_15,
The following exception message is indicating that you're trying to return some object which is not serializable by the service runtime:
"Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface. "
and based on my test, if we simply return the string (by calling ToString on Connection object) in webservice webmethod, it should works correctly (here is the test webmethod I use):
[WebMethod] public string GetConnectionString() { var sqlconn = new SqlConnection(@"data source=.\SQLExpress;initial catalog=Northwind;integrated security=True;"); return sqlconn.ToString(); }Therefore, I'd suggest you recreating a webservice and define a similar webmethod to test it again. Also, you can verify if there is some other webmethods in your service which has directly return the SqlConnection object(that might cause the exception you pasted above).
Feedback to us
Microsoft One Code Framework