我从 MessageQueue 接收我的类型的消息时遇到问题。这是代码:
MyClass myClassObject = null;
var msmq = new MessageQueue(@".\private$\myqueuename")
{Formatter = new XmlMessageFormatter(new Type[] {typeof (MyClass)})};
var receive = msmq.Receive(new TimeSpan(20000000000));
if (receive != null)
{
myClassObject = (MyClass)receive.Body;
}
我希望最终在 myClassObject 中拥有数据。
[DataContract]
public class
MyClass
{
[DataMember]
public long? Id
{
get;
set;
}
.....
}
我错过了什么?非常感谢您!