Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NServiceBus XML序列化程序错误_Nservicebus - Fatal编程技术网

NServiceBus XML序列化程序错误

NServiceBus XML序列化程序错误,nservicebus,Nservicebus,我正在使用NSB 3.0.3。以下是我的项目: 注册。消息(此处所有事件都是命令消息) 注册。域名 注册.事件存储 Registrations.MessageHandlers 注册服务器 服务器正在使用NServiceBus.Host-to-Host nsb。端点配置如下所示: public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization { #region

我正在使用NSB 3.0.3。以下是我的项目:

  • 注册。消息(此处所有事件都是命令消息)
  • 注册。域名
  • 注册.事件存储
  • Registrations.MessageHandlers
  • 注册服务器
服务器正在使用NServiceBus.Host-to-Host nsb。端点配置如下所示:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
    #region Implementation of IWantCustomInitialization

    public void Init()
    {
        var kernel = new StandardKernel();
        kernel.Load(new BackendModule());

        Configure.With()
            .NinjectBuilder(kernel);
    }

    #endregion
}
服务器的配置为:

<?xml version="1.0" encoding="utf-8"?>


我创建了一个测试控制台应用程序,从中发送命令。在NSB发布消息之前,一切正常。例外情况如下:

我创建了我的类来包装NSB:

public class NsbBus : IEventBus
{
    private readonly IBus m_nsb;

    public NsbBus(IBus nsb)
    {
        m_nsb = nsb;
    }

    #region Implementation of IEventBus

    public void Publish<T>(T @event) where T : class, IEvent<IIdentity>
    {
        m_nsb.Publish(@event);
    }

    public void PublishAll<T>(IEnumerable<T> events) where T : class, IEvent<IIdentity>
    {
        m_nsb.Publish(events);
    }

    #endregion
}

Type System.Collections.Generic.List`1[[Aec.Cqrs.IEvent`1[[Aec.Cqrs.IIdentity, Aec.Cqrs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Aec.Cqrs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] was not registered in the serializer. Check that it appears in the list of configured assemblies/types to scan.
公共类NsbBus:IEventBus
{
私有只读IBus m_nsb;
公共NSBBU(IBus nsb)
{
m_nsb=nsb;
}
#IEventBus的区域实施
公共无效发布(T@event),其中T:class,IEvent
{
m_nsb.Publish(@event);
}
public void PublishAll(IEnumerable事件),其中T:class,IEvent
{
m_nsb.出版(活动);
}
#端区
}
未在序列化程序中注册类型System.Collections.Generic.List`1[[Aec.Cqrs.IEvent`1[[Aec.Cqrs.IIdentity,Aec.Cqrs,Version=1.0.0.0,Culture=中立,PublicKeyToken=null]],Aec.Cqrs,Version=1.0.0,Culture=中立,PublicKeyToken=null]]。检查它是否出现在要扫描的已配置程序集/类型列表中。
该程序集Aec.Cqrs在服务器项目中引用并部署到bin目录

我看过类似的帖子,但都是关于网络项目的。这不是一个web项目。知道这里为什么会出现序列化错误吗


谢谢

我不知道为什么,但这解决了问题。我没有将事件集合作为集合传递给NSB的Publish方法,而是为每个事件调用Publish。public void PublishAll(IEnumerable events)where T:class,IEvent{foreach(var@event in events)m_nsb.Publish(@event);}您在哪里得到的异常是什么?(没有出现在Q中)嗨,Andreas,这个例外是最后一个代码区域的一部分。这里又是:键入System.Collections.Generic.List
1[[Aec.Cqrs.IEvent
1[[Aec.Cqrs.IIdentity,Aec.Cqrs,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null]],Aec.Cqrs,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null]]未在序列化程序中注册。检查它是否出现在要扫描的已配置程序集/类型列表中。NSB认为您希望将该列表作为一条消息发送。你能试着把它转换成一个IMessage[]看看是否有用吗?
public class NsbBus : IEventBus
{
    private readonly IBus m_nsb;

    public NsbBus(IBus nsb)
    {
        m_nsb = nsb;
    }

    #region Implementation of IEventBus

    public void Publish<T>(T @event) where T : class, IEvent<IIdentity>
    {
        m_nsb.Publish(@event);
    }

    public void PublishAll<T>(IEnumerable<T> events) where T : class, IEvent<IIdentity>
    {
        m_nsb.Publish(events);
    }

    #endregion
}

Type System.Collections.Generic.List`1[[Aec.Cqrs.IEvent`1[[Aec.Cqrs.IIdentity, Aec.Cqrs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Aec.Cqrs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] was not registered in the serializer. Check that it appears in the list of configured assemblies/types to scan.