Debuging ExcelDna with Visual Studio Code and .NET 6 CLI

344 vues
Passer au premier message non lu

Hubert Domaros

non lue,
29 avr. 2023, 20 h 00 min 42 s2023-04-29
à Excel-DNA
Hello everyone,
First of all, thank you for such great package!
I wanted to ask you about using ExcelDna with VS Code and .NET 6. I know that Visual Studio is main IDE for which ExcelDna is intended, but unfortunately I am not able to use it for now at my workplace for several reasons.

My question is: Have you ever tried to debug an ExcelDna library with VS Code? I am able to create a class library with dotnet new classlib, build the with dotnet build, and even add to excel and run this addin, but I don't have an idea how to attach the debugger.  I tried different solutions, but none of them seems to work- every time program starts and automatically finishes with folowing message:
The program '[18704] ExcelDnaAddinTest.dll' has exited with code -532462766 (0xe0434352).
Here is my launch.json file: https://pastebin.com/akuxjhs9

Do you have any ideas how to solve this problem?
Thanks in advance!

Hubert Domaros

non lue,
1 mai 2023, 09 h 35 min 23 s2023-05-01
à Excel-DNA
Hi,
So after a lot of digging, I found a solution, which looks insanely easy and makes me look dumb:

All you have to do is instead of running the addin dll, in launch.json in property "program" you have to replace the dll with Excel exe path:
"program": "C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE"
and add path to your addin to "args":
"args": ["${workspaceFolder}\\bin\\Debug\\net6.0-windows\\ExcelDnaAddinTest-AddIn64.xll"]

so in my case, whole addin looks like this:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE",
            "args": ["${workspaceFolder}\\bin\\Debug\\net6.0-windows\\ExcelDnaAddinTest-AddIn64.xll"],
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopAtEntry": false
        },      
    ]
}

Happy Open Source coding, folks!

sic con (woomoody)

non lue,
10 janv. 2024, 05 h 46 min 50 s10 janv.
à Excel-DNA

Hello, I noticed that you successfully debugged Excel-DNA code using VSCode. I was wondering if you could kindly provide your successful sample project. I also wish to migrate my project from Visual Studio to VSCode. Thank you.

Terry Aney

non lue,
28 janv. 2024, 17 h 36 min 23 s28 janv.
à Excel-DNA
I was going to attempt to convert a significantly sized ExcelDna adding from .NET Framework to .NET Core.  I also use/prefer VS Code now over VS Proper.  When I followed the simply startup sample from https://excel-dna.net/ home page and debug the project, I get the following dialog:

"Initialization [Error] No objects loaded from KAT.Extensibility.Excel.AddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".

I simply have the bare bones start up of:

```
using ExcelDna.Integration;

namespace KAT.Extensibility.Excel.AddIn;

public static class MyFunctions
{
    [ExcelFunction(Description = "My first .NET function")]
    public static string SayHello(string name)
    {
        return "Hello " + name;
    }
}
```

Did you encounter and overcome this problem?

Govert van Drimmelen

non lue,
28 janv. 2024, 18 h 02 min 51 s28 janv.
à exce...@googlegroups.com
Hi Terry,

It should work.
What does your project file look like?

Also, check that you don't have a .dna file in the project directory. It's now created in the output directory automatically, from project properties.

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/db919653-1fe7-4452-a800-16147872e5cbn%40googlegroups.com.

Terry Aney

non lue,
28 janv. 2024, 19 h 34 min 35 s28 janv.
à Excel-DNA
I've created a new post to keep this post focused.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message