Debugging .Net 8 in VS22 (How to Step Into the Code)

Debugging .Net 8 in VS22 (How to Step Into the Code)

Scott_FergusonPVMNH
Enthusiast Enthusiast
1,969 Views
9 Replies
Message 1 of 10

Debugging .Net 8 in VS22 (How to Step Into the Code)

Scott_FergusonPVMNH
Enthusiast
Enthusiast

I am having problems understanding how to debug (step into) my library project (.dll) now that I have switch to .Net 8.

I have tried updating the launchSettings.json file and it doesn't work for me.

Can someone please explain how we do this now that we have switched to .Net 8?

I need to be able to step through my code and I am really hoping someone has the answer.

0 Likes
Accepted solutions (1)
1,970 Views
9 Replies
Replies (9)
Message 2 of 10

Scott_FergusonPVMNH
Enthusiast
Enthusiast
Accepted solution

I found this guide and it answered my question of how to set up the executable path.
https://forums.autodesk.com/t5/net/migration-guide-net-framework-to-autocad-2025-net-8-0/td-p/126762...

FYI VS22 would not try to use the acad.exe executable when I clicked the Run arrow until I put something in the command line arguments window: e.g. /product ACAD /language "en-US"

 

0 Likes
Message 3 of 10

kerry_w_brown
Advisor
Advisor

 

Yes, I believe that post thread should be pinned to the top of the forum listing.

It  would sure save a lot of repeat posts 🙂

 

Thanks again to Gilles

 

Regards,

 

 

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
Message 4 of 10

Scott_FergusonPVMNH
Enthusiast
Enthusiast
Yes I agree it should be pinned to the top! 🙂

Searching in the forums for the solution returned no hits at all.
0 Likes
Message 5 of 10

kerry_w_brown
Advisor
Advisor

@Scott_FergusonPVMNH 

 

I add a TestCommands class to my Library.

I add a breakpoint to the line in the Test CommandMethod I want to use.
Call the Test Method from the CommandLine after the Assembly is Netloaded.

From there just Step Into (F11) the highlighted line.

Make sure that Hot Reloading is enabled.

 

I exclude the TestCommands class from the 'published' build


Regards,


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 6 of 10

kerry_w_brown
Advisor
Advisor

@Scott_FergusonPVMNH wrote:

FYI VS22 would not try to use the acad.exe executable when I clicked the Run arrow until I put something in the command line arguments window: e.g. /product ACAD /language "en-US"


Re your revised response :

 

For launchSettings.json I use a variation of  :

{
  "profiles": {
    "KdubServices.Acad.Common": {
      "commandName": "Executable",
      "executablePath": "C:\\Program Files\\Autodesk\\AutoCAD 2025\\acad.exe",
      "commandLineArgs": "/nologo /b \"start.scr\""
    }
  }
}

. . . with the start.scr netloading the Assembly.

. . . and I leave the working directory as the default assembly .dll location.

 

Regards,


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
Message 7 of 10

dba78
Advocate
Advocate

Though I can debug the .net8-Plugins in Acad2025 (AdvanceSteel 2025 - to be accurate), I face a new issue, have no idea where it comes from:

On starting the debugger, all the Exceptions in the CLR-Environments get caught, thrown by Autocad-Libs... 😬

this makes debugging to a horror...

Couldn't figure out, how to suppress those. Any ideas?

Thanks in Advance!!!

 

PS: No issues debugging ADVS 2024 + .net Framework 4.8

0 Likes
Message 8 of 10

norman.yuan
Mentor
Mentor

The first picture shows clearly that your code is wrong: The last line should be boo.l.Parse(...):

 

public static bool Parse(string value)

{

    ArgumentNullException.ThrowIfNull(value);

    return bool.Parse(value);

}

 

OTH, without seeing your all code, I do not see why you need this extension method. You simply can directly call bool.Parse() anywhere you want to use this extension method.

 

As for the second picture, again, not seeing all relevant code, or knowing what your are doing, I do not want to guess, other than saying it is very likely your code is wrong and you should fix the code other than looking a way to "suppress" VS showing exception.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 9 of 10

dba78
Advocate
Advocate

This is exactly my point, this isn't my code, as you can see in the second picture.

It seems to be a call to System.Private.CoreLib.dll by AdWindows.dll.

The exception throws as soon as I start debugging on acad-init..

🤔

 

there are bunch of others too.... 🙄

 

0 Likes
Message 10 of 10

norman.yuan
Mentor
Mentor

Ah, I see. It seems it is AutoCAD's InfoCenter is trying to collect some data that is related to Advanced Steel that causes issues, because InfoCenter does work OK with my Acad2025/C3D2025 on multiple computer when Visul Studio debugs. 

 

It may or may not be a bug of Advanced Steel on Autodesk side, but since we, as programmers, could not be careless more about Info center while writing code, you might want to try to disable Info Center to see if the issue goes away. Here is what I got by searching "AutoCAD disable infocenter":

normanyuan_0-1731336471072.png

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes