& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
Hi,
I am trying to debug a C# AutoCAD plug-in I made. I am using Visual Studio 2019 and AutoCAD 2020. I am using the "Start External Program" feature and upon pressing play, Visual Studio should open AutoCAD. It attempts to do this, but I get this message:
If I open AutoCAD manually and then netload my dll, no problem. But if Visual Studio tries to open AutoCAD, it won't do it. I need to open it this way because I am debugging my application. I am using the Managed .NET API with C#. How do I avoid running my managed code in DllMain? I am new to programming and can't figure this one out. Any help would be much appreciated!
Solved! Go to Solution.
I tried this already. Visual Studio attempts to open AutoCAD, then just abruptly stops. Pretty much the same as before but without the warning.
@jmcfarland1996
Could you capture your Project properties\ application and Project properties\ debug?
I have 2 assumptions:
1. Maybe something wrong with your project's Target framework, be sure to set project Target framework to .Net framework 4.7 (not 4.7.1 nor 4.7.2)
2. Maybe something wrong with your Debug\ Start external program, it should be (if autocad installed to default folder):
"C:\Program Files\Autodesk\AutoCAD 2020\acad.exe"
Make sure you in debug mode and not release mode.
I was using .NET Framework 4.8, but I just changed it to 4.7 and it didn't help. Using a later version of .NET Framework than is necessary for a version of AutoCAD shouldn't hurt right? I remember I had successfully linked Visual Studio to AutoCAD on a previous project, and I just tried using that one and now it isn't working either! I don't know what happened...
From my poor experiences, I'm afraid that you've started with wrong project type.
For VS 2019, I started from the type "WPF app (.Net framework)", and Project properties\ application\ Application type (Output type) should be: "WPF class library" not "Class library"
*
Here is my project properties, it works with CV3D 2022. The project can show user form over CV3D,
Yes all three are set to false. I tried the "Start Without Debugging" button and it loaded AutoCAD just fine. It is only when I try to open it for debugging that it throws the exception.
Another possible clue: The breakpoints are disabled with this message:
The breakpoint will not currently be hit. No Symbols have been loaded for this document.
I appreciate the help, but I have seen videos of people debugging with class library templates and I know it is possible. I have not yet attempted a WPF app in AutoCAD. I don't think this is the source of the problem. I tried checking the "Enable native code debugging" box in the debug menu. It then tries to load AutoCAD but endlessly tries to load symbols. Sometimes it gives me this error:
Update 7/2: After creating a test C# project with "Autocad 2022 Dotnet Wizard", I find out that the C# project type created by the wizard is non-WPF.
(This is different from the VB project type created by the wizard (WPF))
With C# project created by the Wizard, I can start Autocad 2022 from VS debug after turn off Loader Lock.
I also attach the solution with C# project created by the wizard.
*
*
*
I've checked the sample solution at:
C:\Program Files\Autodesk\AutoCAD 2022\C3D\Sample\Civil 3D API\DotNet
If the Output type is "Class Library" then Debug\ Start external program is unchecked.
In this case I can still debug by:
1. In the same solution of your existing project, add another WPF project, declare Application & Debug tab, declare references as your existing project (I'm not sure if it is necessary), set the WPF as your startup project.
2. From VS 2019, start debug (F5) to open Acad.exe, in that Acad.exe instance, netload the existing non-WPF project .dll file which is located in \bin\Debug folder.
*
By the way, the previous WPF project I showed you was a mimic of another created by Autocad 2018 VB plug-in for VB.net in VS 2015. Don't understand why it must be WPF, but it is working.
Sorry if this is a dumb question, but what do you mean by installed? I am still pretty new to this so let me just run through what I am doing. I am using the class library template, writing some code, then building to make a dll file. I then open AutoCAD and netload that dll. I have been doing this for a while with no problems. But now my applications are getting more complicated and I want to debug my code. I thought the way to do this was to press the start button, and add AutoCAD to the "start external program" option. This is how I would debug a console app.
Am I missing something? What process do you go through to debug class libraries used in AutoCAD?
Go to this page
https://www.autodesk.com/developer-network/platform-technologies/autocad
Scroll to the end of the page, you will see the Dotnet Wizard (a plug-in / template for MS Visual studio)
For VS 2019, it is the 2021 and 2022 DotNet Wizard
Hey guys, update here. Thank you for all your help, I really appreciate it. I tried everything but nothing worked. Eventually I decided to start fresh with a new version of AutoCAD and Visual Studio. (I had been meaning to make the change anyway and as a member of the ADN this came at no extra cost to me.) After installing AutoCAD 2022, everything worked just fine! I think there may have been an issue with the particular version of AutoCAD I was using. It was an old student version of AutoCAD 2020 which was entitled "Civil 3D As AutoCAD". My best guess is that there was something wrong with the configuration file associated with that version. But who knows.
I am still using the class library template, but now that or any other template seems to be working fine. I use the template which is made for the type of project that I will be working on. I have not yet used the .NET wizard. I just set up my files manually and it only takes me a few seconds. But once again, thank you for your advice and the thought you put into this!
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name