【发布时间】:2015-07-09 14:39:42
【问题描述】:
我正在尝试使用 ExcelDNApack.exe 将我的所有 dll 打包到 XLL 中,为此我使用以下命令及其为我生成的 pack xll 文件。
"$(SolutionDir)dependencies\Excel-DNA.0.32.0\tools\ExcelDnaPack.exe"
"$(TargetDir)ExcelTrader-AddIn.dna" /Y
但是当我从没有依赖 dll 的文件夹中运行 xll 文件时,它会抛出异常“调用函数 OnLoad 时发生异常”。异常消息是无法加载文件或程序集 '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>
【问题讨论】: