Change Dll loaded with MEF

柔情痞子 提交于 2019-12-03 16:39:49

You need to enable shadow copying in the AppDomain, this forces the application to behave similarly to a web app where the executable content is not running from the source location, but a temporary location.

The only problem you have is either

  1. Use an obselete method AppDomain.CurrentDomain.SetShadowCopyFiles() which forces it on the the current domain. Not advisable as this has been deprecated in favour of:
  2. Use AppDomainSetup.ShadowCopyFiles = "true"; when creating a new AppDomain. You then need to defer execution of the your assembly in the other AppDomain. Maybe this form post can help?

I'm not sure you can enable Shadow Copying through application configuration...

If you try to insert on catalog one Object Assembly like this:

Assembly assembly = Assembly.Load(System.IO.File.ReadAllBytes(Path.Combine(directoryPath, ItemPlugin)));
aggregateCatalog.Catalogs.Add(new AssemblyCatalog(assembly));

You can Delete\Change the file later...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!