title: No destination specified for message, but my NServiceBus configuration appears to setup correctly
body: <p>I have created a standard NServiceBus publish subscribe program.  I keep getting the following error when sending a message to my publisher NServicBus host:</p>
  
  <p>No destination specified for message TrackEventPublisher.TrackEventPublisher.InternalMessages.TrackEventMessages. Message cannot be sent. Check the UnicastBusConfig section in your config file and ensure that a MessageEndpointMapping exists for the message type.</p>
  
  <p>Well.... the MessageEndpointMapping exists!</p>
  
  <p>Here is my test console application code I use to test the MessagePublisher class:</p>
  
  <pre><code>class Program
     {
        static void Main(string[] args)
        {
           Console.WriteLine("Click enter to submit message.");
           Console.ReadLine();
  
           string aMessage = "Please Work!!!!!!!!";
           MessagePublisher publisher = new MessagePublisher();
           publisher.PublishEventMessage(aMessage);
        }
     }
  </code></pre>
  
  <p>Here is my message sender class which sends a message to another NServiceBus publish server to be published:</p>
  
  <pre><code>   public class MessagePublisher
     {
        public IBus Bus { get; set; }
  
        public MessagePublisher()
        {
           BusInitializer.Init();
           Bus = BusInitializer.Bus;
        }
  
        public void PublishEventMessage(string message)
        {
           Bus.Send(new TrackEventMessages(message));
        } 
     }
  </code></pre>
  
  <p>My bus initializer:</p>
  
  <pre><code>   class BusInitializer
     {
        public static IBus Bus { get; private set; }
  
        public static void Init()
        {
           Bus = NServiceBus.Configure.With()
               .Log4Net()
               .DefaultBuilder()
               .XmlSerializer()
               .MsmqTransport()
                   .IsTransactional(false)
                   .PurgeOnStartup(false)
               .UnicastBus()
                   .LoadMessageHandlers()
                   .ImpersonateSender(false)
               .CreateBus()
               .Start();
        }
     }
  </code></pre>
  
  <p>My message class:</p>
  
  <pre><code>namespace TrackEventPublisher.TrackEventPublisher.InternalMessages
  {
      public class TrackEventMessages : IMessage
      {
         public string HelloWorldMessage { get; set; }
  
         public TrackEventMessages(string message)
         {
            HelloWorldMessage = message;
         }
      }
  }
  </code></pre>
  
  <p>And finally, my configuration for the message publisher:</p>
  
  <pre><code>namespace TrackEventPublisher.PublishManager
  {
      public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
      {
      }
  }
  
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" /&gt;
      &lt;section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" /&gt;
    &lt;/configSections&gt;
  
    &lt;MsmqTransportConfig InputQueue="PublishManager" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" /&gt;
  
    &lt;UnicastBusConfig ForwardReceivedMessagesTo=""&gt;
      &lt;MessageEndpointMappings&gt;
        &lt;add Messages="TrackEventPublisher.TrackEventPublisher.InternalMessages" Endpoint="TrackEventPublisher" /&gt;
      &lt;/MessageEndpointMappings&gt;
    &lt;/UnicastBusConfig&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The configuration was created by the NServiceBus auto-generator.  The configuration appears to be correct.  Does anyone have any idea why I get the InvalidOperationException "No destination specified for message" when sending the message via:</p>
  
  <pre><code>    Bus.Send(new TrackEventMessages(message));
  </code></pre>
  
  <p>Thanks in advance.  I have spend waaaay too much time on this one.</p>
  
  <p><em><strong></em>* Update <em>*</em>*</strong></p>
  
  <p>I may be setting up the Bus incorrectly from my MessagePubliser class.  My goal is to instantiate the MessagePublisher class from another application (wpf, console, etc).  That is why I am using a BusInitializer class.  However, the Bus I am creating does not correlate with my app.config in the MessagePublisher class.<br>
  Does anyone have a good idea how to instantiate the MessagePublisher class so my bus recognizes the app.config?   Perhaps using IWantToRunAtStartup?</p>