【发布时间】:2014-01-17 10:09:25
【问题描述】:
说来话长……抱歉。
我正在使用PartUpdatesInPlace 中的示例并更改代码,以便在从扩展路径中删除它后重新加载 Extensions1.dll。
我在删除 Extensions1.dll 后设置了一个断点,将其更改为 Bar 使其返回不同的字符串重新编译然后刷新目录,希望在 OnImportsStatisfied 运行时,它会返回更新后的字符串,但它不会。
按照原版,ShadowCopyAssembly 已启用。
/// setup catalogs and container and instance of BarWatcher
Console.WriteLine("Press enter to add a new bar");
Console.ReadLine();
//copy in a bar and refresh
File.Copy(BinDir + @"..\..\..\PartUpdatesInPlaceExtensions2\bin\debug\PartUpdatesInPlaceExtensions2.dll", ExtensionsPath + "Extensions2.dll");
directoryCatalog.Refresh();
Console.WriteLine("Press enter to remove the first bar");
Console.ReadLine();
//delete the original bar and refresh
File.Delete(ExtensionsPath + "Extensions1.dll");
directoryCatalog.Refresh();
//在下面设置断点行 Console.WriteLine("回车重新添加原栏"); Console.ReadLine(); //复制到一个栏中并刷新 File.Copy(BinDir + @"......\PartUpdatesInPlaceExtensions\bin\debug\PartUpdatesInPlaceExtensions.dll", ExtensionsPath + "Extensions1.dll"); directoryCatalog.Refresh();
container.Compose(batch);
Console.ReadLine();
我可以将所有代码添加到存储库中,如果这样可以更简单的话。我的“Microsoft.Composition”版本是 1.0.20(从 Nuget 获得)
任何想法为什么会发生这种情况?
据我了解,recomposition 应该会发生,因为它已在 BarWatcher
中启用 [Export]
public class BarWatcher : IPartImportsSatisfiedNotification
{
[ImportMany(AllowRecomposition = true)]
public IEnumerable<IBar> Bars { get; set; }
public void OnImportsSatisfied()
{
if (Bars.Any())
{
foreach (var bar in Bars)
Console.WriteLine("bar-"+bar.Foo());
}
else
Console.WriteLine("No Bars present");
Console.WriteLine("\n");
}
}
【问题讨论】:
标签: c# mef shadow-copy