Peter Lényi
Peter Lényi

Reputation: 85

MEF part's dependency

I have a problem regarding MEF. In essence:

assembly my.main {
  class Main {
    <Import>
    Lazy<IMyType> prop;

    public static void Main(...) {
      ComposeParts(this);
      prop.DoStuff();
    }
  }
}

assembly my.interfaces {
  interface IMyType {
    void DoStuff();
  }
}

assembly my.parts {
  using 3rdParty;
  <Export>
  class MyType : IMyType {
    void DoStuff() {
      3rdParty.DoStuff();
    }
  }
}

Both my.main and my.parts reference my.interfaces assembly. In addition to that, my.parts assembly references a 3rd party .dll, which my other two do not. When I try to execute the above, a CompositionException is thrown in Main() when calling prop.DoStuff() with the message saying the class 3rdParty could not be found.

In other words, MEF part is injected, but the dll it requires is not injected/copied.

Does anyone know a solution or workaround to this problem?

Upvotes: 1

Views: 182

Answers (1)

twoflower
twoflower

Reputation: 6830

During execution, the 3rdParty assembly file is apparently not located in the same directory as the my.parts assembly (or in any other location the loader probes).

Upvotes: 1

Related Questions