![](/img/trans.png)
[英]“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.