如何在队列浏览器中使用.net视图

时间:2018-06-26 12:57:22

标签: c# nservicebus msmq

我们公司使用的是Cogin的Queue Explorer 4.0 pro,我一直在他们的网站上进行搜索,在使用他们的.net视图时,我唯一能找到的就是关于查看通过.net程序集解析的消息的一点点迷离。 :blog post

例如,我的信息正文是这样:

<?xml version="1.0"?>
<CreateAuditLogEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.net/Phone.Messages">
    <SurveyId>12345</SurveyId>
    <AuditEventId>704</AuditEventId>
    <EventDateTime>2018-06-08T13:21:07.6647304Z</EventDateTime>
</CreateAuditLogEntry>

并且我尝试使用我们告诉NServicebus使用的程序集来发送上述消息。它没有SerializableAttribute,所以我想我将使用相同的名称空间创建自己的程序集并尝试添加所有相同的内容:

namespace Phone.Messages
{
    [System.Serializable]
    public class CreateAuditLogEntry
    {
        public long SurveyId { get; set; }
        public int AuditEventId { get; set; }
        public System.DateTime EventDateTime { get; set; }
    }
}

我编译了该代码,然后将Queue Explorer指向它,它告诉我它仍然无法反序列化该对象:Error: Cannot deserialize the message passed as an argument. Cannot recognize the serialization format.有没有人使用它并使它成功工作?

1 个答案:

答案 0 :(得分:1)

该xmlns部分似乎是这里的问题。通过XmlRoot属性指定该名称空间时,您的示例将起作用:

[XmlRoot(Namespace="http://tempuri.net/Phone.Messages")]
public class CreateAuditLogEntry
{
    public long SurveyId { get; set; }
    public int AuditEventId { get; set; }
    public System.DateTime EventDateTime { get; set; }
}

顺便说一句。 QueueExplorer动态加载为.Net视图指定的程序集,如果您重建并创建新的dll / exe,则不必重新启动它。