Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel DNA packing issue

Tags:

c#

excel-dna

I am trying to pack all my dlls into XLL using the ExcelDNApack.exe, for this I am using below command and its generating pack xll file for me.

"$(SolutionDir)dependencies\Excel-DNA.0.32.0\tools\ExcelDnaPack.exe" 
"$(TargetDir)ExcelTrader-AddIn.dna" /Y

But when I am running the xll file from the folder where I dont have dependent dlls its throwing an exception "An Exception occured while calling function OnLoad". The exception message is Could not load file or assembly 'OpenApiSecurityLib, version=1.0.0.0,Culture=neutral,PublicKeyToken=null'

I have a main project ExcelTrader.dll which references OpenAPISecurityLib.dll and OpenAPIClientLib.dll, I have added Reference attribute in the dna file for both these dlls and dependencies and added ExternalLibrary attribute for ExcelTrader.dll

If I put both OpenAPISecurityLib.dll and OpenAPIClientLib.dll in the same folder as xll file, XLL file runs perfectly fine

Please suggest what is that I am doing wrong here Thanks

<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>
like image 912
saurabh vats Avatar asked Feb 15 '26 06:02

saurabh vats


1 Answers

My issue got resolved I checked that in the output 'Reference with Path: System.Threading.Tasks.Dataflow.dll and Name: not found.' after this exception rest of the references were getting ignored.

I checked that the dll reference for which the error was coming is no more in use in our project after removing reference for this dll everything worked fine.

like image 166
saurabh vats Avatar answered Feb 17 '26 20:02

saurabh vats



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!