我正在尝试使用 ExcelDNApack.exe 将我所有的 dll 打包到 XLL 中,为此我使用下面的命令及其为我生成的 pack xll 文件。
"$(SolutionDir)dependencies\Excel-DNA.0.32.0\tools\ExcelDnaPack.exe"
"$(TargetDir)ExcelTrader-AddIn.dna" /Y
但是当我从没有依赖 dll 的文件夹中运行 xll 文件时,它会抛出异常“调用函数 OnLoad 时发生异常”。异常消息是 Could not load file or assembly 'OpenApiSecurityLib, version=1.0.0.0,Culture=neutral,PublicKeyToken=null'
我有一个引用 OpenAPISecurityLib.dll 和 OpenAPIClientLib.dll 的主项目 ExcelTrader.dll,我在 dna 文件中为这些 dll 和依赖项添加了 Reference 属性,并为 ExcelTrader.dll 添加了 ExternalLibrary 属性
如果我将 OpenAPISecurityLib.dll 和 OpenAPIClientLib.dll 放在与 xll 文件相同的文件夹中,XLL 文件运行得很好
请指出我在这里做错了什么谢谢
<DnaLibrary Name="ExcelTrader Add-In" RuntimeVersion="v4.0">
<Reference Path="Newtonsoft.Json.dll" Pack="true" />
<Reference Path="NLog.dll" Pack="true" />
<Reference Path="Microsoft.Practices.Unity.Configuration.dll" Pack="true" />
<Reference Path="Microsoft.Practices.Unity.dll" Pack="true" />
<Reference Path="Microsoft.Practices.Unity.RegistrationByConvention.dll" Pack="true" />
<Reference Path="Microsoft.AspNet.SignalR.Client.dll" Pack="true" />
<Reference Path="System.Threading.Tasks.Dataflow.dll" Pack="true" />
<Reference Path="System.Net.Http.Formatting.dll" Pack="true"/>
<Reference Path="OpenApiClientLib.dll" Pack="true" />
<Reference Path="OpenApiSecurityLib.dll" Pack="true" />
<ExternalLibrary Path="ExcelTrader.dll" Pack="true" />
<!-- Some images that can be used in the Ribbon ui -->
<Image Name="Login" Path="Images\Login.gif" Pack="true" />
<Image Name="LogOut" Path="Images\LogOut.png" Pack="true" />
<CustomUI>
<customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui' loadImage='LoadImage' onLoad='OnLoad'>
<ribbon>
<tabs>
<tab id='CustomTab' label='Excel Trader'>
<group id='loginCtrl' label='Login Control'>
<button id='btnLogin' label='Login' getEnabled='GetEnabled' image='Login' size='large' onAction='OnLogin' />
<button id='btnLogOut' label='LogOut' image='LogOut' size='large' onAction='OnLogOut' />
</group >
</tab>
</tabs>
</ribbon>
</customUI>
</CustomUI>
</DnaLibrary>
最佳答案
我的问题已解决 我在输出中检查了“引用路径:System.Threading.Tasks.Dataflow.dll 和名称:未找到。”在此异常之后,其余引用将被忽略。
在删除对该 dll 的引用后,我检查了出现错误的 dll 引用是否不再在我们的项目中使用,一切正常。
关于c# - Excel DNA 打包问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31288561/