webservice 为什么不能强制转换
webservice[WebMethod(Description = "aa")]
public CustomerDeviceInfoEntity GetNamefromCustomerid(int customerid)
{
CustomerDeviceInfoEntityCollection coll = CustomerDeviceInfoEntity.SelectWhere(" customerid='" + customerid + "'");
if (coll.Count > 0)
return coll[0];
else
return null;
}
调用页
CustomerDeviceInfoEntity ent = new CustomerDeviceInfoEntity();
ent = (CustomerDeviceInfoEntity)web.GetNamefromCustomerid(11);
this.TextBox1.Text = ent.RecordDateTime.ToString();
编译后提示错误
无法将类型“DemoWeb.localhost.CustomerDeviceInfoEntity”转换为“IDH.DAO.CustomerDeviceInfoEntity” D:\mxy\DemoWeb\DemoWeb\WebForm1.aspx.cs 48 18 DemoWeb
请问这个怎么调用啊
--------------------编程问答-------------------- 错误提示很明显嘛.
CustomerDeviceInfoEntity 这个类, WebService端和你的调用页要使用的是同一个引用.
你的代码里出现了两个(命名空间不同). 故而不能转换.
DemoWeb.localhost.CustomerDeviceInfoEntity
IDH.DAO.CustomerDeviceInfoEntity --------------------编程问答-------------------- 他们两个引用的是同一个DLL啊
--------------------编程问答-------------------- 你检查下看看了,如果是同一个DLL, 咋会出现命名空间不同的情况呢.(鼠标放在类名上智能提示,看全名是否一样). 另忘说了,就是CustomerDeviceInfoEntity 这个类必须支持序列化,才可以在webService传输.
补充:.NET技术 , Web Services