简体   繁体   English

未检查MEF插件依赖性未加载为插件目录

[英]MEF plugin dependency not loading as plugins directory is not checked

I'm having problems with MEF not picking up dependencies for loaded components. 我遇到了MEF没有为加载的组件获取依赖关系的问题。 We have a directory structure that looks like: 我们有一个目录结构,如下所示:

C:/MSMQ/DistributionService/[Main application] C:/ MSMQ / DistributionService / [主要应用]

C:/MSMQ/Providers/[plugin components] C:/ MSMQ / Providers / [插件组件]

Of course, we are using a DirectoryCatalog, the plugin is picked up, but one of its' dependencies is not. 当然,我们正在使用DirectoryCatalog,该插件被选中,但其中一个依赖项不是。 The error message is: 错误消息是:

2012-11-02 10:46:59,379 [1] FATAL - Assemblies required by Provider are not found
System.IO.FileNotFoundException: Could not load file or assembly 'BusinessObjects, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'BusinessObjects, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null'

=== Pre-bind state information ===
LOG: User = <redacted>
LOG: DisplayName = BusinessObjects, Version=1.5.0.0, Culture=neutral, Public
KeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/MSMQ/DistributionService/
LOG: Initial PrivatePath = NULL
Calling assembly : DistributedServicePropertyComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\MSMQ\DistributionService\Distr
ibutionService.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\
v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partia
l, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

2012-11-02 10:46:59,401 [1] FATAL - Assemblies required by Provider are not found
System.IO.FileNotFoundException: Could not load file or assembly 'BusinessObjects, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'BusinessObjects, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null'

=== Pre-bind state information ===
LOG: User = B2B\addisona
LOG: DisplayName = BusinessObjects, Version=1.5.0.0, Culture=neutral, Public
KeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/MSMQ/DistributionService/
LOG: Initial PrivatePath = NULL
Calling assembly : DistributedServicePropertyComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\MSMQ\DistributionService\DistributionService.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\
v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

I believe this is similar to a question on MSDN: http://social.msdn.microsoft.com/Forums/en-US/MEFramework/thread/b34ef4f4-e1f1-4f06-bd42-d7b3d5060f6f/ - but I don't understand the answer. 我相信这类似于MSDN上的一个问题: http//social.msdn.microsoft.com/Forums/en-US/MEFramework/thread/b34ef4f4-e1f1-4f06-bd42-d7b3d5060f6f/ - 但我不明白答案。

Is there any way to provide a path to pick the problem assembly up from, or any other suggested solution? 有没有办法提供从中提取问题的路径,或任何其他建议的解决方案?

We have only started having this problem recently, but I can't see any changes I'd expect to cause that in our source control history. 我们最近才开始遇到这个问题,但是在我们的源代码管理历史记录中,我看不到任何我希望发生的变化。

One or more of your plugins are dependent on the BusinessObjects assembly, while your host application does not reference this assembly. 您的一个或多个插件依赖于BusinessObjects程序集,而您的宿主应用程序不引用此程序集。 You can do either of the following to fix this: 您可以执行以下任一操作来解决此问题:

  1. Add a reference to this assembly from your main application, so that the plugins can use it when they are loaded. 从主应用程序添加对此程序集的引用,以便插件在加载时可以使用它。
  2. Add this assembly to your C:\\MSMQ\\Providers directory, so that when the plugins are loaded and look for that assembly, they can find it and load it as well. 将此程序集添加到C:\\ MSMQ \\ Providers目录中,以便在加载插件并查找该程序集时,他们可以找到它并加载它。

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

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