包含C ++ / CLI库的ExcelDnaPack.exe

我用ExcelDNA创build一个Excel插件,使用ExcelDnaPack.exe打包成一个单一的xll。 它工作得很好,直到我添加一个C ++ / CLI项目(称为CPPLibrary.dll)创build一个dll的引用当我打包CPPLibrary.dll时,外挂程序在运行时抱怨,它无法find该DLL。 如果我离开CPPLibrary.dll解压,只是复制它在-packed.xll一切工作的目录。 有没有办法将C ++ / CLI项目成功打包到ExcelDNa插件中?

谢谢。

我最终将c ++ / cli作为资源embedded,并在实时Excel的加载时得到加载我提取embedded式DLL到磁盘中的文件,并执行Assembly.LoadFrom(提取的path)像这样:

private static void ExtractAndLoadCPPLibrary() { var executingAssembly = Assembly.GetExecutingAssembly(); string resource_path = "mydnaassembly.Embedded.CPPLibrary.dll"; var version = executingAssembly.GetName().Version.ToString().Replace(".","_"); var output_Path = Path.Combine(Path.GetTempPath(), "CPPLibrary_" + version + ".dll"); if (!File.Exists(output_Path)) { using (Stream cpplibrary_input = executingAssembly.GetManifestResourceStream(resource_path)) using (var cpplibrary_output = File.Create(output_Path)) { cpplibrary_input.CopyTo(cpplibrary_output); } } Assembly assembly = Assembly.LoadFrom(output_Path); }