Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 应用程序位于网络共享上时的MEF组合_.net_Mef_Composition - Fatal编程技术网

.net 应用程序位于网络共享上时的MEF组合

.net 应用程序位于网络共享上时的MEF组合,.net,mef,composition,.net,Mef,Composition,我有一个MEF应用程序,在本地运行时效果很好,但在网络共享上远程调用时却不起作用 我使用Assembly.LoadFrom来避免UNC问题,但是由于所有DLL都位于exe旁边,我真的不认为这会是问题所在,但我尝试了任何方法 我还修复了ConfigurationManager.GetSection问题,在查看之后,这似乎是.NET 4权限的常见问题 我在配置文件中允许。所以我不确定问题出在哪里 编辑:异常中的ProductDispatcher在catalog.Parts中是明确的 设置容器和目录的

我有一个MEF应用程序,在本地运行时效果很好,但在网络共享上远程调用时却不起作用

我使用Assembly.LoadFrom来避免UNC问题,但是由于所有DLL都位于exe旁边,我真的不认为这会是问题所在,但我尝试了任何方法

我还修复了ConfigurationManager.GetSection问题,在查看之后,这似乎是.NET 4权限的常见问题

我在配置文件中允许
。所以我不确定问题出在哪里

编辑:异常中的ProductDispatcher在catalog.Parts中是明确的

设置容器和目录的代码:

var catalog = new AggregateCatalog();

var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

foreach (string file in Directory.GetFiles(dir, "XXX*.dll"))
{
    var assembly = Assembly.LoadFrom(file);
    catalog.Catalogs.Add(new AssemblyCatalog(assembly));
}

var container = new CompositionContainer(catalog);
var batch = new CompositionBatch();
batch.AddPart(this);
container.Compose(batch);
导入内容是(我已尝试公开):

似乎MEF在部分信任场景中工作得不太好。是否需要执行任何操作以确保所有操作都在完全信任的情况下运行?

尽管您启用了“从远程源加载”,但可能会发生这种情况,因为文件可能仍然对其有限制

NTFS支持将元数据应用于备用数据流(ADS)中的文件。这将包括区域信息(例如互联网区域等)

这可能是导致位于网络的文件出现问题的原因,这些文件可能在Internet区域中被分类,因此仍有可能被阻止


查看本文,看看这是否能为您解决问题:

我的项目也有同样的问题,但不幸的是,我一直无法解决这个问题:(
[ImportMany(typeof(IEntityTypeDispatcher))]
private IEnumerable<IEntityTypeDispatcher> Dispatchers { get; set; }
[Export(typeof(IEntityTypeDispatcher))]
internal class ContactDispatcher : EntityTypeDispatcher<Contact>
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Resulting in: An exception occurred while trying to create an instance of type 'XXX.XXX.Dispatch.ProductDispatcher'.

Resulting in: Cannot activate part 'XXX.XXX.Dispatch.ProductDispatcher'.
Element: XXX.XXX.Dispatch.ProductDispatcher -->  XXX.XXX.Dispatch.ProductDispatcher -->  AssemblyCatalog (Assembly="XXX.XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")

Resulting in: Cannot get export 'XXX.XXX.Dispatch.ProductDispatcher (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher")' from part 'XXX.XXX.Dispatch.ProductDispatcher'.
Element: XXX.XXX.Dispatch.ProductDispatcher (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher") -->  XXX.XXX.Dispatch.ProductDispatcher -->  AssemblyCatalog (Assembly="XXX.XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")

Resulting in: Cannot set import 'XXX.XXX.Dispatch.DispatcherRepository.Dispatchers (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher")' on part 'XXX.XXX.Dispatch.DispatcherRepository'.
Element: XXX.XXX.Dispatch.DispatcherRepository.Dispatchers (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher") -->  XXX.XXX.Dispatch.DispatcherRepository
 (System.ComponentModel.Composition.CompositionException)

   at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.Compose(CompositionBatch batch)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.Compose(CompositionBatch batch)
   at XXX.XXX.Dispatch.DispatcherRepository.LoadDispatchers() in D:\Workspaces\XXX\Branches\Dev1\XXX.XXX\XXX.XXX\Dispatch\DispatcherRepository.cs:line 71
   at XXX.XXX.Dispatch.DispatcherRepository.get_Instance() in D:\Workspaces\XXX\Branches\Dev1\XXX.XXX\XXX.XXX\Dispatch\DispatcherRepository.cs:line 34
   at XXX.XXX.Dispatch.DispatcherRepository.GetDispatchers() in D:\Workspaces\XXX\Branches\Dev1\XXX.XXX\XXX.XXX\Dispatch\DispatcherRepository.cs:line 21
   at XXX.XXX.Dispatch.Dispatcher.get_Instance() in D:\Workspaces\XXX\Branches\Dev1\XXX.XXX\XXX.XXX\Dispatch\Dispatcher.cs:line 30
   at XXX.XXX.Broker..ctor() in D:\Workspaces\XXX\Branches\Dev1\XXX.XXX\XXX.XXX\Broker.cs:line 52