MEF插件依赖未加载,因为插件目录未被检查。

7

我在使用MEF加载组件时遇到了依赖项无法被识别的问题。我们的目录结构如下:

C:/MSMQ/DistributionService/[主应用程序]

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

当然,我们正在使用DirectoryCatalog,插件已经被识别,但其中一个依赖项没有被识别。错误消息如下:

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.

我相信这与MSDN上的一个问题类似:http://social.msdn.microsoft.com/Forums/en-US/MEFramework/thread/b34ef4f4-e1f1-4f06-bd42-d7b3d5060f6f/,但我不理解答案。
是否有任何方法提供从中获取问题程序集的路径或任何其他建议的解决方案?
我们最近才开始遇到这个问题,但我看不到在源代码控制历史记录中引起此问题的任何更改。

你是否正在尝试从已签名(或延迟签名)的代码中加载程序集? - tom redfern
据我所知,签名代码并未涉及(除了框架库)。 - penguat
你是在尝试从32位代码中加载64位程序集吗? - tom redfern
嗨penguat - 你解决了这个问题吗?我也遇到了同样的问题。 - Pat Hastings
@PatrickHastings 我们把所有东西都塞进了一个文件夹。虽然不够优雅,但它能正常工作。 - penguat
1个回答

1

您的一个或多个插件依赖于BusinessObjects程序集,而您的主机应用程序没有引用此程序集。您可以执行以下任一操作来解决此问题:

  1. 从您的主应用程序中添加对此程序集的引用,以便在加载插件时可以使用它。
  2. 将此程序集添加到C:\MSMQ\Providers目录中,以便在加载插件并查找该程序集时,可以找到并加载它。

5
这个程序集在 C:\MSMQ\Providers 目录下,但找不到它。 - penguat

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接