简体   繁体   English

MEF部分的依赖性

[英]MEF part's dependency

I have a problem regarding MEF. 我对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. my.mainmy.parts都引用my.interfaces程序集。 In addition to that, my.parts assembly references a 3rd party .dll, which my other two do not. 除此之外, my.parts程序集还引用了第三方.dll,而我的另外两个则没有。 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. 当我尝试执行上述操作时,在调用prop.DoStuff()时,在Main()中引发了CompositionException ,并显示一条消息,指出未找到3rdParty类。

In other words, MEF part is injected, but the dll it requires is not injected/copied. 换句话说,MEF部分已被注入,但是它所需的dll没有被注入/复制。

Does anyone know a solution or workaround to this problem? 有人知道该问题的解决方案或解决方法吗?

在执行期间,显然3rdParty程序集文件与my.parts程序集不在同一目录中(或装入程序探查的任何其他位置)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM