Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging fails when <ExcelDnaUnpack>true<ExcelDnaUnpack> is set #695

Open
govert opened this issue May 14, 2024 · 0 comments
Open

Debugging fails when <ExcelDnaUnpack>true<ExcelDnaUnpack> is set #695

govert opened this issue May 14, 2024 · 0 comments

Comments

@govert
Copy link
Member

govert commented May 14, 2024

With the project option to make an output 'publish' directory with a completely-unpacked add-in, the add-in we get in the output folder does not work anymore. The -AddIn64.xll here does not contain the packed ExcelDna.* assemblies, but they are not present in this directory either. When starting to debug, we get
image

One option is to copy back the ExcelDna.*.dll files from the publish directory

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
      <!-- Copy all ExcelDna.*.dll files back to the output directory -->
    <Exec Command="xcopy &quot;$(OutputPath)publish\ExcelDna.*.dll&quot; &quot;$(OutputPath)&quot; /Y /I /S" />
  </Target>

But then opening the add-in without the debugger crashes Excel, and with the debugger we get this unhandled exception in the loading
image

The culprit in this case (which makes the output directory different to the publish directory) is the presence of an <MyProject>-AddIn64.deps.json file. This file does not list the extra ExcelDna.Loader.dll, and this causes the load to fail for some reason (it would be nice to know why). This seems to have changed in Excel-DNA version 1.7.0 (and is reported to still have worked in 1.6.0, I haven't checked).

By deleting the <MyProject>-AddIn64.deps.json file we get an output directory that can be debugged.
This can be done in another project task:

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    
    <!-- Copy all ExcelDna.*.dll files back to the output directory -->
    <Exec Command="xcopy &quot;$(OutputPath)publish\ExcelDna.*.dll&quot; &quot;$(OutputPath)&quot; /Y /I /S" />
    
    <!-- Delete <ProjectName>-AddIn64.deps.json from the output directory -->
    <Message Text="Deleting $(OutputPath)$(MSBuildProjectName)-AddIn64.deps.json" Importance="high" />
    <Exec Command="del /Q &quot;$(OutputPath)$(MSBuildProjectName)-AddIn64.deps.json&quot;" />
    
    <!-- Delete <ProjectName>-AddIn.deps.json from the output directory -->
    <Message Text="Deleting $(OutputPath)$(MSBuildProjectName)-AddIn.deps.json" Importance="high" />
    <Exec Command="del /Q &quot;$(OutputPath)$(MSBuildProjectName)-AddIn.deps.json&quot;" />

  </Target>

It is possible to edit the .deps.json file to add the ExcelDna.Loader.dll but that doesn't seem like a practical approach:

      "ExcelDna.Integration/1.8.0-rc": {
        "runtime": {
          "lib/net6.0-windows7.0/ExcelDna.Integration.dll": {
            "assemblyVersion": "1.1.0.0",
            "fileVersion": "1.8.0.4"
          },
          "ExcelDna.Loader.dll": {}
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant