我开发一个Excel VSTO文档级外接使用复合应用程序指南(棱镜为Visual Studio 2008/.NET 3.5)。可扩展的Excel VSTO加载使用棱镜/ CAG /统一调试
其中一个要求是,此加载应该是可扩展的,也就是在运行时它应该允许加载插件的DLL。我创建统一的目录模块目录是这样的:
// the path where the WorkbookProject.dll Add-In (WorkbookProject\bin\Debug) resides
string fullPath = AppDomain.CurrentDomain.BaseDirectory;
string theDirectory = Path.GetDirectoryName(fullPath);
return new DirectoryModuleCatalog() { ModulePath = fullPath };
我的简化项目的层次结构是这样的:
Common
-ref: none
WorkbookProject // the main project with xlsx workbook (shouldn't reference any PlugIns)
-ref: Common
PluginOne
-ref: Common
-PostBuildEvent copies output dll to WorkbookProject\bin\Debug
Setup (temporarily knows all plugins, but they should be installed separately)
-ref: Common
-ref: PluginOne
-ref: WorkbookProject
这一部署后工作正常(所有DLL驻留在应用程序文件夹由安装程序创建项目),但在调试期间我得到Microsoft.Practices.Composite.Modularity.ModuleCatalog.Load()
异常:
System.IO.FileLoadException: API restriction: The assembly 'file:///(...)\WorkbookProject\bin\Debug\Common.dll' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.
在Visual Studio输出/调试窗口,我可以看到,该文件已经从
C:\Users\Me\AppData\Local\assembly\dl3\JWCWD78V.HAZ\H2VHNAYM.XW1\18912686\7e8ea552_620acc01\Common.dll
加载为什么(从WorkbookProject参考)我所有的应用程序文件的调试过程中被复制到AppData目录?可以避免这种情况吗?
难道有所作为,如果我转换从我的工作簿添加项目,在对应用程序插件?