我试图通过消息检查器在消息的标题中传输一些用户信息。如何通过WCF中的标题传输对象
我创建了一个将检查器添加到服务(客户端和服务器)的行为。
但是当我尝试与服务,我碰到下面的错误进行通信:
XmlException:
名称不能以“<”字符,十六进制值开始为0x3C。
我也得到异常告诉我,DataContracts出乎意料。
Type 'System.DelegateSerializationHolder+DelegateEntry' with data contract name 'DelegateSerializationHolder.DelegateEntry: http://schemas.datacontract.org/2004/07/System ' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
的事情是,我的对象包含了被标记为DataContract其他的目的和我没有兴趣加入这些类型的KnownType
属性。
另一个问题可能是我的对象序列化是在内部类和内部性能等的形式非常有限
任何人都可以指导我在正确的方向。我做错了什么?
一些代码:
public virtual object BeforeSendRequest(ref Message request, IClientChannel channel)
{
var header = MessageHeader.CreateHeader("<name>", "<namespace>", object);
request.Headers.Add(header);
return Guid.NewGuid();
}
对不起,误解,但尖括号里只是为了说明它是一些名称和一些命名空间。我可以看到关于错误消息的混淆。不,实际代码没有尖括号,但名称空间是http:// formattet名称空间。 – Michael 2010-04-06 06:40:37