Asp.net 将邮件消息发送到消息队列时出错

Asp.net 将邮件消息发送到消息队列时出错,asp.net,msmq,Asp.net,Msmq,我正在尝试将消息(复杂类型)发送到消息队列。我收到错误消息,ETravel.Web,版本=1.0.0.0,区域性=中性,PublicKeyToken=null'未标记为可序列化。下面是相关代码 public void QueueMessage(EmailMessage message) { Message msg = new Message(); msg.Body = message; msg.Recove

我正在尝试将消息(复杂类型)发送到消息队列。我收到错误消息,
ETravel.Web,版本=1.0.0.0,区域性=中性,PublicKeyToken=null'未标记为可序列化
。下面是相关代码

 public void QueueMessage(EmailMessage message)
        {
            Message msg = new Message();
            msg.Body = message;
            msg.Recoverable = true;
            msg.Formatter = new BinaryMessageFormatter();
            string queuePath = @".\private$\WebsiteEmails";
            //InsureQueueExists(queuePath);
            MessageQueue msgQ;
            msgQ = new MessageQueue(queuePath);
            msgQ.Formatter = new BinaryMessageFormatter();
            msgQ.Send((object)msg);
        }
复杂类型的EmailMessage如下所示

public class EmailMessage
    {
        public string subject { get; set; }
        public string message { get; set; }
        public string from { get; set; }
        public string to { get; set; }
    }
提前谢谢

我已经安装了MessageQueue

操作系统:windows xp。

使用的技术:Asp.net mvc。

您是否将该类标记为[可序列化]

 [Serializable]
 public class EmailMessage
 { ..... }
也 您没有序列化它的方法 在使用非内置对象时,应该告诉您如何使用序列化对象

//Deserialization
public EmailMessage(SerializationInfo info, StreamingContext ctxt)
{


to = (string)info.GetValue("to", typeof(string));
from = (String)info.GetValue("from", typeof(string));
// add other stuff here
}

//Serialization function.

public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{

// then you should read the same with "EmployeeId"

info.AddValue("to", to);
info.AddValue("from", from);
}
编辑:对不起,我想的是BinaryFormatter而不是BinaryMessageFormatter。尽管你仍然可以试试看它是否有效

问候