title: Receiving null exception when using MEF import in a class library "Object reference not set to an instance of an object"?
body: <p>I am experiencing a strange issue when trying to use the import MEF paradigm in a c# class library project. Basically I have another DLL which has the implementation for IDevicePreferences. When calling devicePreferences.Callsign I receive the following exception:</p>
  <pre><code>System.NullReferenceException: 'Object reference not set to an instance of an object.'
  
  devicePreferences was null.
  </code></pre>
  <p>I am embedding this class library project in a DLL which is used in my other project. In other words I am trying to do MEF in a class library via instantiating a WeatherClient object in a standard C# .Net project which has the DLL. (My Project -&gt; My Class Library -&gt; IDevicePreferences DLL)</p>
  <p>Interestingly, I am able to implement the IDevicePreferences interface in my project (I have the DLL for that there as well) without issue. But I can't get it to work from <em>inside</em> my class Library / WeatherClient class.</p>
  <p>Here is the WeatherClient class:</p>
  <pre class="lang-cs prettyprint-override"><code>public class WeatherClient
  {
      [Import(typeof(IDevicePreferences))]
      public IDevicePreferences devicePreferences;
  
      public WeatherClient(String serverIp, int port)
      {
          this.serverIp = serverIp;
          this.port = port;
          System.Diagnostics.Debug.WriteLine(&quot;callsign: &quot; + devicePreferences.Callsign);
      }
  }
  
  </code></pre>
  <p>Any ideas on what I am doing wrong?</p>