“System.ComponentModel.PropertyChangedEventHandler”不能从特殊类派生'System.MulticastDelegate“ [英] 'System.ComponentModel.PropertyChangedEventHandler' cannot derive from special class 'System.MulticastDelegate'

查看:1011
本文介绍了“System.ComponentModel.PropertyChangedEventHandler”不能从特殊类派生'System.MulticastDelegate“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个WCF服务作为推荐的此处。开发原.NET 2.0的Web服务时,它解决了我的名字空间的冲突最初的问题,但我想出了另一个问题。



这是我想传递给WCF服务的对象是在客户端用于聚集了一堆从用户信息和它的一些领域都是数据绑定到UI控件(因此实施PropertyChangedEventHandler)。当我尝试编译由SvcUtil工具生成的代理在我的客户项目,我得到的错误标题这个问题。



拉的所有数据出这个对象,并把进入到一个类用于发送(然后重构原始型)似乎多余 -​​ 更不用说采取一个可笑的很长一段时间。



有一种解决方法。

解决方案

我可以检查?你是一个合格的代表的到Web服务?这是行不通的...它*不能序列化。充其量,ADO.NET数据服务(.NET 3.5SP1)可以做到通过把一个表达式进入查询字符串类似的东西...但是,这是接近你会得到。除此之外,你必须建立一个封装与常规性的意图请求对象。



这适用于任何网络服务,WCF服务,TCP的, 。等等



* =委托基本上是一个类型安全的方法处理(带有可选的目标(例如)参考);它可表示,例如,以XML



<小时/>



(编辑)

从意见 - 这可能只是你还没有归咎于你的数据合同;这意味着它具有推断合同(而且往往得到它是错误的)。例如:

  [DataContract] 
类Foo:IWhateverInterfaces {
[数据成员]
公共字符串酒吧{获取;集;}

[数据成员]
公众诠释巴兹{获取;设置;}

公众持股量NotPartOfTheContract {获取;集;}

公共事件的EventHandler AlsoNotPartOfTheContract;
}

在使用 [DataContract] ,只标出成员 [数据成员] 被序列化 - 这样的事件应该被忽略。这曾经是在做WCF数据契约的方式,但MS调整它来推断领域...合同的错误海事组织,因为它会导致你刚才出现了问题......


I'm developing a wcf service as recommended here. It solved my initial problem of namespace conflicts when developing the original .NET 2.0 web service, but I've come up to another problem.

The object that I'm trying to pass to the wcf service is used in the client to aggregate a bunch of information from the user and some of its fields are databound to ui controls (hence implementing PropertyChangedEventHandler). When I try to compile the proxy generated by svcutil in my client project, I get the error that titles this question.

Pulling all of the data out of this object and putting into into a class for sending (and then reconstructing the original type) would seem redundant - not to mention take a ridiculously long time.

Is there a workaround?

解决方案

Can I check? Are you passing a delegate to a web service? That won't work... it* cannot be serialized. At best, ADO.NET Data Services (.NET 3.5SP1) can do something similar by translating an Expression into a query-string... but that is as close as you'll get. Other than that, you'll have to build a request object that encapsulates your intent with regular properties.

This applies to any of web-service, wcf service, tcp, etc.

*=a delegate is essentially a type-safe method handle (with an optional target (instance) reference); it can be expressed, for example, as xml


(edit)

From the comments - it might simply be that you haven't attributed your data-contracts; this means it has to infer the contract (and it often gets it wrong). For example:

[DataContract]
class Foo : IWhateverInterfaces {
    [DataMember]
    public string Bar {get;set;}

    [DataMember]
    public int Baz {get;set;}

    public float NotPartOfTheContract {get;set;}

    public event EventHandler AlsoNotPartOfTheContract;
}

When using [DataContract], only members marked [DataMember] are serialized - so the event should be ignored. This used to be the only way of doing WCF data-contracts, but MS tweaked it to infer contracts from fields... a mistake IMO, as it causes the problem you've just had...

这篇关于“System.ComponentModel.PropertyChangedEventHandler”不能从特殊类派生'System.MulticastDelegate“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆