title: Masstransit sending ICommand
body: <p>I have a list of ICommand that I store in the DB for a legacy process manager (I don't have time to convert all the code to using Sagas just yet)</p>
  
  <p>I need to be able to deserialize the list of commands and send them.</p>
  
  <p>In order to be able to represent the commands in c# I have a List</p>
  
  <p>looping through the list and calling send on each one causes a problem because Masstransit only sees an ICommand and not the underlying type (even though the commands are serialized with type info</p>
  
  <p>Here is an example of the code:</p>
  
  <pre><code>if (deserializedCommands == null)
  {
     deserializedCommands = this._serializer.Deserialize&lt;IEnumerable&lt;Envelope&lt;ICommand&gt;&gt;&gt;(undispatched.Commands).ToList();
  
     while (deserializedCommands.Count &gt; 0)
     {
         var cmd = deserializedCommands.First();
  
         this._commandBus.Publish(cmd.Body).Wait();
  
         deserializedCommands.RemoveAt(0);
     }
  }
  </code></pre>
  
  <p>Hovering over cmd.Body in the debugger shows the correct type.</p>
  
  <p>But Masstransit only sees ICommand:</p>
  
  <blockquote>
    <p>A convention for the message type xxxx.ICommand was not found</p>
  </blockquote>
  
  <p>How can I make it so MT sees the correct type?</p>
  
  <p>Googling brings up something about EndpointConvention but it doesn't look like it's documented or complete, there's also talk about topology but i can't find anything about that. </p>
  
  <p>What can I do to make this work? I am using the castle windsor integration and loading my command handlers through <code>ep.LoadFrom(container);</code> </p>
  
  <p>[UPDATE]</p>
  
  <p>I can get the underlying type of the message using:</p>
  
  <pre><code>var type = cmd.Body.GetType();
  </code></pre>
  
  <p>Is there anyway to use that type as a generic argument for:</p>
  
  <pre><code>this._commandBus.Send(cmd.Body).Wait();
  </code></pre>
  
  <p>I guess is the question?</p>