[英]“The type RoleProxy was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.” NHibernate
[英]The type xxx was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically
因此,当我可以在MSMQ上放置一条消息时,旧的代码库工作正常。 但是,我收到的新代码库无法正常工作,不知道说实话我缺少什么。
基类:
[DataContract]
[KnownType(typeof (ReportA))]
[KnownType(typeof (AUpdate))]
[KnownType(typeof (AStatusReport))]
[KnownType(typeof (MsgHeader))]
[KnownType(typeof(BRegistationReport))]
[KnownType(typeof(BAlarmReport))]
[KnownType(typeof(AlarmData))]
[KnownType(typeof(DmpAlarmData))]
public class MyMessage {....}
然后是此处的特定类BAlarmReport(源自MyMessage):
[DataContract]
public class BAlarmReport: MyMessage
{ ... }
然后,您可以将AlarmData作为继承自DmpAlarmData的基础:
[DataContract]
public class DmpAlarmData : AlarmData
{ .. }
我将其放置在MSMQ上的方式与之前相同,直到获得新的代码库之前,该方式一直有效:
var queue = new MessageQueue(@"FormatName:Direct=OS:" + mMSMQQueueNameAndLocation);
var msg = new Message {Body = MyMessage.CreateMessage() };
using (var ts = new TransactionScope(TransactionScopeOption.Required))
{
queue.Send(msg, MessageQueueTransactionType.Automatic); // send the message
ts.Complete(); // complete the transaction
}
我错过了什么吗?
固定。 叹
深入研究内部异常会导致我遇到一些类没有无参数构造函数的问题。 但是子类也应该使用基类本身的XmlInclude属性声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.