title: Where to place AutoMapper map registration in referenced dll
body: <p>This is my first AutoMapper project and may be obvious to some but the tutorials and examples are not clicking with me. I am trying to understand where and to a certain degree how to register(I think I want profiles) my maps for use. There are plenty of MVC examples saying to use the global asax and this makes sense but what is the equivalent in a library project?</p>
  
  <p>In my sandbox I have a winform app and a core library. The winform app calls methods made available by the library and it is one of these library methods that makes use of automapper.</p>
  
  <p>So for some background here is my map: 
  (and to be clear the mapping is in the SAME core library project)</p>
  
  <pre><code>public class Raw_Full_Map    
  {
      public Raw_Full_Map()
      {
  
          Mapper.CreateMap&lt;IEnumerable&lt;RawData&gt;, FullData&gt;()
              .ForMember(d =&gt; d.Acres, m =&gt; m.ResolveUsing(new RawLeadDataNameResolver("Acres")));
         //this is clearly just a snip to show it's a basic map
      }
   }
  </code></pre>
  
  <p>This is the core library method being called: (note it is a static..which means I won't have a constructor...if this is the problem am I to understand then that AutoMapper can't be utilized by static helper classes...that doesn't make sense....so likely I'm just not doing it right.</p>
  
  <pre><code>public static class RawDataProcessing
  {
  
      public static FullData HTMLDataScrape(string htmlScrape)
      {
  
          HtmlDocument doc = new HtmlDocument();
          doc.LoadHtml(htmlScrape);
  
          var list = Recurse(doc.DocumentNode);
          //HTML agility stuff that turns my html doc into a List&lt;RawData&gt; object
  
  
          return Mapper.Map&lt;FullData&gt;(list);
  
  
      }
  </code></pre>
  
  <p>My test harness calls it like this:</p>
  
  <pre><code>var _data = RawDataProcessing.HTMLDataScrape(rawHTML);
  </code></pre>
  
  <p>This of course errors because the map isn't "registered".</p>
  
  <p>If I do this in the test harness:</p>
  
  <pre><code>var x = new RawData_FullData();
  
  var _data = RawDataProcessing.HTMLDataScrape(rawHTML);
  </code></pre>
  
  <p>Then everything works as my map get's registered albeit I think in a really bogus way...but it does work.</p>
  
  <p>So the question is how do I register my mapping in the core library project...so that ANY method can use it...there isn't really an equivalent global.asax in a dll is there?</p>
  
  <p>Thank you for helping me connect the missing pieces.</p>