silverlight webservice 数据访问时出错
请各位帮忙解决,
错误信息:
尝试对参数 http://tempuri.org/ 进行反序列化时出错
-----------------------------------------
[WebMethod]
public user[] GetUsers()
{
SqlConnection _sqlConnection = new SqlConnection();
_sqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["sqlConnectionString"].ToString();
_sqlConnection.Open(); SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand("SELECT top 200 * FROM test", _sqlConnection);
DataSet ds = new DataSet();
da.Fill(ds);
List<user> u = new List<user>() ;
foreach (DataRow dr in ds.Tables[0].Rows)
{
user CC = new user();
CC.JS_BH = dr["JS_BH"].ToString();
CC.XM = dr["XM"].ToString();
CC.BYYX = dr["BYYX"].ToString();
CC.ZY = dr["ZY"].ToString();
CC.GZNY = dr["GZNY"].ToString();
u.Add(CC);
}
return u.ToArray();
}
------------------------sl中调用-----------------------------
private void Page_Loaded(object sender, RoutedEventArgs e)
{
usera1.Service1SoapClient cl = new SilverlightApplication3.usera1.Service1SoapClient();
cl.GetUsersAsync();
cl.GetUsersCompleted+=new EventHandler<SilverlightApplication3.usera1.GetUsersCompletedEventArgs>(cl_GetUsersCompleted);
}
void cl_GetUsersCompleted(object sender, SilverlightApplication3.usera1.GetUsersCompletedEventArgs e)
{
if (e.Error == null)
{
this.dgPelope.ItemsSource = e.Result; //绑定结果到UI的List控件
}
}
[解决办法]
确认user实体有没有标记序列化,有没有特殊的类型。