tags:

views:

180

answers:

1

My GenericHost hosted service is failing to start with the following message:

2010-05-07 09:13:47,406 [1] FATAL NServiceBus.Host.Internal.GenericHost [(null)] <(null)> - System.InvalidOperationException: No message serializer has been con figured. at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.CheckConfiguration() in d:\BuildAgent-02\work\672d81652eaca4e1\src\impl\unicast\NServiceBus.Unicast.Msmq\ MsmqTransport.cs:line 241 at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.Start() in d:\BuildAgent-02\work\672d81652eaca4e1\src\impl\unicast\NServiceBus.Unicast.Msmq\MsmqTransport .cs:line 211 at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start(Action startupAction) in d:\BuildAgent-02\work\672d81652eaca4e1\src\unicast\NServiceBus.Uni cast\UnicastBus.cs:line 694 at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start() in d:\BuildAgent-02\work\672d81652eaca4e1\src\unicast\NServiceBus.Unicast\UnicastBus.cs:l ine 665 at NServiceBus.Host.Internal.GenericHost.Start() in d:\BuildAgent-02\work\672d81652eaca4e1\src\host\NServiceBus.Host\Internal\GenericHost.cs:line 77

My endpoint configuration looks like:

public class ServiceEndpointConfiguration
    : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
    public void Init()
    {
        // build out persistence infrastructure
        var sessionFactory = Bootstrapper.InitializePersistence();

        // configure NServiceBus infrastructure
        var container = Bootstrapper.BuildDependencies(sessionFactory);

        // set up logging
        log4net.Config.XmlConfigurator.Configure();

        Configure.With()
            .Log4Net()
            .UnityBuilder(container)
            .XmlSerializer();
    }
}

And my app.config looks like:

<configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
    <section name="Logging" type="NServiceBus.Config.Logging, NServiceBus.Core" />
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
</configSections>

<Logging Threshold="DEBUG" />

<MsmqTransportConfig
    InputQueue="NServiceBus.ServiceInput"
    ErrorQueue="NServiceBus.Errors"
    NumberOfWorkerThreads="1"
    MaxRetries="2" />

<UnicastBusConfig
    DistributorControlAddress=""
    DistributorDataAddress=""
    ForwardReceivedMessagesTo="NServiceBus.Auditing">
    <MessageEndpointMappings>
        <!-- publishers don't need to set this for their own message types -->
    </MessageEndpointMappings>
</UnicastBusConfig>

<connectionStrings>
    <add name="Db" connectionString="Data Source=..." providerName="System.Data.SqlClient" />
</connectionStrings>

<log4net debug="true">
    <root>
        <level value="INFO"/>
    </root>
    <logger name="NHibernate">
        <level value="ERROR" />
    </logger>
</log4net>

This has worked in the past, but seems to be failing when the generic host starts. My endpoint configuration is below, along with the app.config for the service. What is strange is that in my endpoint configuration, I am specifying to use the XmlSerializer for message serialization. I don't see any other errors in the console output preceding the error message. What am I missing?

Thanks, Steve

+1  A: 

It looks like this was my own issue, though I had a hard time figuring that out based on the error message that I received. I have a base class for all of my messages:

public abstract class RequestMessage : IMessage {} 

Recently, I created a partner message:

public abstract class ResponseMessage<TRequest> 
    where TRequest : RequestMessage {}

Apparently, when the host was starting up the IStartableBus, it would hit this generic message type and would not handle it correctly. I only really saw the underlying error when running with the DefaultBuilder, rather than the UnityBuilder that I am using in my project. It had something to do with the generic type constraint. I had assumed that this would work, but sadly it did not.

Regards, Steve

SteveBering
Thanks, +1 for saving me time trying to figure out what was causing the error. The message serialiser doesn't appear to like generic interfaces. Not had time to see what is needed to get it working, but rolled back a change and doing it with out generics for time being
Paul Hadfield