我在我的项目中使用WCF服务。该服务返回一个名为“Store”的类。我创建了一个从“Store”继承的新的本地类。我的班级被称为“ExtendedStore”。 我ExtendedStore看起来是这样的:如何正确地扩展WCF返回的类?
class ExtendedStore : StoreManagerService.Store
{
public int Id;
....
}
现在我使用的WCF服务的内容投射到我的课用下面的代码:
StoreManagerService.StoreClient client = new StoreManagerService.StoreClient();
ExtendedStore store = (ExtendedStore) client.GetStore(); // bombs here
我无法从投返回的存储类服务到我的ExtendedStore类。 我得到以下错误信息:
无法转换 类型的对象ConsoleApplication1.StoreManagerService.Store“ 键入 “ConsoleApplication1.ExtendedStore”。
我不应该能够施放它吗?如果没有,是否有解决方法?
可能是最简单的解决方案,如果他实际上正在生成代理。我觉得你有一个继承问题有点奇怪,但是不能通过部分类机制来扩展类。不从班级继承的原因也适用于以这种方式扩展,即imo。 – Thorarin 2010-05-20 18:58:13
现在我将如何使用这个部分课程? – vikasde 2010-05-20 19:02:06
感谢您的帮助。 – vikasde 2010-05-20 19:52:43