title: NService Bus Exception while Handling onStart when Assembly depends on Automapper
body: <p>We have an assembly using a refernce to the Automapper.dll. Starting the NServiceBus as Subscriber fails on Start with the following message:</p>
  
  <pre><code>Exception when starting endpoint, error has been logged. Reason: Could not load file or assembly 'file:///D:\Main\Src\Core\Core.MessageHandler\bin\Debug\AutoMapper.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
  </code></pre>
  
  <p>StackTrace:</p>
  
  <pre><code>Server stack trace: 
         at Magnum.StateMachine.ExceptionActionDictionary`1.HandleException(T stateMachine, Event event, Object parameter, Exception exception)
         at Magnum.StateMachine.EventActionList`1.Execute(T stateMachine, Event event, Object parameter)
         at Magnum.StateMachine.EventActionBase`1.Execute(T instance, Event event, Object parameter)
         at Magnum.StateMachine.State`1.RaiseEvent(T instance, BasicEvent`1 eevent, Object value)
         at Magnum.StateMachine.StateMachine`1.RaiseEvent(Event raised)
         at Topshelf.Internal.ServiceController`1.Start()
         at Topshelf.Internal.IsolatedServiceControllerWrapper`1.Start()
         at Topshelf.Internal.ServiceControllerProxy.Start()
         at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]&amp; outArgs)
         at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]&amp; outArgs)
         at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
  
      Exception rethrown at [0]: 
         at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
         at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
         at Topshelf.Internal.ServiceControllerProxy.Start()
         at Topshelf.Internal.FacadeToIsolatedServiceController`1.Start()
         at Topshelf.Internal.ServiceCoordinator.Start()
         at Topshelf.Internal.Hosts.ConsoleHost.Run()
         at Topshelf.Internal.Actions.RunAsConsoleAction.Do(IRunConfiguration configuration)
         at Topshelf.Runner.Host(IRunConfiguration configuration, String[] args)
         at NServiceBus.Host.Program.Main(String[] args)
  </code></pre>
  
  <p>The file "Automapper.dll" exists! There is no problem in the Config. I checked this removing the dependency to the AutoMapper.dll and it works.</p>
  
  <p>Here is the config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="MsmqTransportConfig" 
               type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" /&gt;
      &lt;section name="Logging" type="NServiceBus.Config.Logging, NServiceBus.Core" /&gt;
    &lt;/configSections&gt;
  
    &lt;MsmqTransportConfig 
      InputQueue="MyQueue@localhost" 
      NumberOfWorkerThreads="1" 
      MaxRetries="10" 
      ErrorQueue="ErrorQueue@localhost" /&gt;
  
    &lt;Logging Threshold="WARN" /&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Any idea? Are there known problems with AutoMapper dependencies in NServiceBus?</p>