Getting Started with Visual Studio for AutoCAD: From Zero to a Working Plugin in 60 Minutes
A walkthrough for AutoCAD engineers who've never written C# — install Visual Studio, set up an AutoCAD plugin project, and load a working Hello World command via NETLOAD. Pre-warned for every install gotcha.
Getting Started with Visual Studio for AutoCAD: From Zero to a Working Plugin in 60 Minutes
Every solar engineer who's written AutoLISP eventually hits the same wall: the thing they want to automate isn't a drawing operation. It's a proper Windows file dialog, not the broken one LISP gives you. It's a palette with dropdowns that doesn't look like it was designed in 1994. It's a .NET library that parses Excel files or makes an HTTP call to a permit tracker. Or it's the simple problem of shipping a plugin to a coworker without emailing them a .lsp file and writing a three-paragraph email explaining where to put it. AutoLISP has no answer for any of those. C# .NET plugins do.
By the end of this post you'll have Visual Studio installed, an AutoCAD plugin project set up, and a working Hello World command loaded into AutoCAD via NETLOAD. Plan for 60 minutes. Every gotcha is pre-warned.
Why C# is worth a steeper learning curve than LISP
Before spending an hour installing things, it's fair to ask whether this is actually worth it. Here's what C# unlocks that AutoLISP cannot do:
Modern Windows UI. AutoCAD palettes, real dialogs with dropdowns and checkboxes, file pickers that don't feel like they're from Windows 98. LISP's DCL dialog system is effectively frozen at its mid-90s design. C# gives you WPF and WinForms — the same UI toolkit the rest of Windows uses.
Any .NET library, immediately. Need to read an Excel file? There's ClosedXML. Need to parse JSON from a SolarEdge API response? There's System.Text.Json. Need to write to a database? There's Entity Framework. The entire .NET ecosystem — thousands of battle-tested libraries — is available with a single right-click in Visual Studio.
Distributable as a .dll. When you're done, you ship your coworker one file. They type NETLOAD, pick the file, and they're done. No instructions. No "make sure it's in the support file path." No prayer.
Type safety. AutoLISP will happily run until the moment it explodes, usually inside AutoCAD with a cryptic error. C# catches the majority of errors at compile time — before you ever open AutoCAD — because the compiler knows what type every variable is and will tell you when something doesn't match.
A real debugger. You can pause execution, inspect every variable, step through your code line by line. This alone is worth the install.
None of this means throw out your LISP. If you have working routines that do in-AutoCAD geometry work — array blocks, fillet corners, purge layers — leave them alone. They're fast, they're already written, and they work. Use C# for the things LISP can't reach: external data, real UI, distributable tooling.
Step 1: Install Visual Studio Community
Go to visualstudio.microsoft.com/downloads and download Visual Studio Community. It's free.
This is Visual Studio, not Visual Studio Code. These are two completely different products from the same company. VS Code is a lightweight text editor. Visual Studio is a full IDE with a C# compiler, a .NET project system, and a debugger. If you've used VS Code for anything, set that knowledge aside — the interface is different and the workflow is different. You need Visual Studio.
Run the installer. It will download a small bootstrapper first, then launch the Visual Studio Installer, which is itself a separate application that manages Visual Studio. This is normal. Keep clicking through until you hit the Workloads screen — that's where you make the one important decision.
The total download is 8–10 GB. If you're on a slower connection, start this now and come back.
Step 2: Install the .NET desktop development workload
The Visual Studio Installer shows a grid of "Workloads" — bundles of components for different kinds of development. Web development, mobile, games, data science, and several others.
You need exactly one: ".NET desktop development". Check that box. It gives you the C# compiler, the project templates for class libraries and Windows apps, and the debugger.
Do not check other workloads to be safe. Each one adds 2–3 GB. You don't need Azure development. You don't need Python development. You don't need the game engine tools. Check the one box and click Install.
The install takes 15–25 minutes depending on your internet speed and your machine. Go make coffee. When it finishes, Visual Studio will offer to launch. Let it.
First launch asks you to sign in with a Microsoft account. This is optional for 30 days, after which Community requires a free account to keep working. Create one if you don't have one — it's the same account as Outlook or Xbox, and it costs nothing. Pick the General development settings or the C# settings when it asks about your environment. Skip the rest of the customization screens.
Step 3: Find your AutoCAD installation directory
Before you write a line of code, you need two files from your AutoCAD installation:
acmgd.dllacdbmgd.dll
These are the bridge between your plugin and AutoCAD's internal API. They live with AutoCAD, not with Visual Studio.
The default location for most AutoCAD versions:
C:\Program Files\Autodesk\AutoCAD 2025\
Replace 2025 with your version year. If you're on AutoCAD 2023, the folder is AutoCAD 2023. Open File Explorer, navigate there, and confirm both files exist before continuing. They will be there if AutoCAD is installed — this is just a verification step.
Do not copy these files anywhere. You're going to reference them in place. Copying them and keeping two versions in sync is a maintenance headache, and it's unnecessary.
Step 4: Create a new Class Library project
Open Visual Studio. On the start screen, click "Create a new project".
In the search box at the top of the dialog, type Class Library.
Several results will appear. The one you want is "Class Library (.NET Framework)" — the template that shows C# as the language and .NET Framework as the platform type. It usually has a small C# icon and says ".NET Framework" in the description text below the name.
Do not pick "Class Library" without the .NET Framework qualifier. That template targets .NET Core (or .NET 5/6/7/8), which AutoCAD cannot load. The distinction matters and the names are frustratingly similar. Look for the parenthetical — it must say .NET Framework.
If you don't see the .NET Framework template at all, you didn't install the .NET desktop development workload in Step 2. Close Visual Studio, re-run the Visual Studio Installer, and add that workload.
Name the project HelloAutoCAD. For the location, use something like C:\dev\HelloAutoCAD.
Avoid putting this on OneDrive. If your Documents folder syncs to OneDrive, and you create the project there, OneDrive will try to sync the build output while you're compiling. This causes intermittent file lock errors that are genuinely confusing the first time you hit them. A folder directly on C: is cleaner.
For the Framework version at the bottom of the dialog: pick .NET Framework 4.8 for AutoCAD 2021 or newer. For AutoCAD 2019–2020, pick 4.7. AutoCAD 2025 requires 4.8.
Click Create. Visual Studio opens with a single file, Class1.cs, already in the editor. Leave the file open but delete all its contents — you'll replace them in Step 6.
Step 5: Add the AutoCAD references
In the Solution Explorer panel (right side of the screen by default), find the References node under your project. Right-click it and choose "Add Reference...".
In the Reference Manager dialog, click Browse at the bottom left. A file picker opens. Navigate to your AutoCAD installation folder:
C:\Program Files\Autodesk\AutoCAD 2025\
Hold Ctrl and click both acmgd.dll and acdbmgd.dll to select both at once. Click Add, then click OK.
Both files now appear under References in Solution Explorer. Now do this for each one:
Click on acmgd in the References list. In the Properties panel at the bottom of Solution Explorer (you may need to press F4 to show it), find the "Copy Local" property. Set it to False. Repeat for acdbmgd.
If you skip this step, AutoCAD will crash when you NETLOAD the plugin. When Copy Local is True, Visual Studio copies those .dlls into your build output folder. When AutoCAD loads your plugin, it finds two copies of acmgd.dll — the one it already loaded, and the one from your build folder — and .NET's assembly binding resolver gets confused and throws an unhandled exception. Setting Copy Local to False means your build folder contains only your plugin's .dll, and AutoCAD's own copies of those files are used.
Save the project with Ctrl+S.
Step 6: Write the Hello World command
Replace the entire contents of Class1.cs with the following:
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
[assembly: CommandClass(typeof(HelloAutoCAD.Commands))]
namespace HelloAutoCAD
{
public class Commands
{
[CommandMethod("HELLOSOLAR")]
public void HelloSolar()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
doc.Editor.WriteMessage("\nHello from a .NET plugin. AutoLISP, eat your heart out.");
}
}
}
What each piece does:
-
[assembly: CommandClass(typeof(HelloAutoCAD.Commands))]— This line sits outside the namespace block and tells AutoCAD which class contains the plugin's commands. AutoCAD scans for this attribute when it loads the .dll. If it's missing, NETLOAD will appear to succeed but none of your commands will be registered. -
[CommandMethod("HELLOSOLAR")]— This attribute registersHELLOSOLARas an AutoCAD command. Whatever string you put here becomes the command name the user types at the AutoCAD prompt. -
Application.DocumentManager.MdiActiveDocument— Gets the currently active document. The AutoCAD .NET equivalent of querying which drawing is open. You'll use this constantly. -
doc.Editor.WriteMessage(...)— Writes text to the AutoCAD command line. The C# equivalent of(princ "...")in AutoLISP. The\nat the start pushes output to a new line so it doesn't run together with whatever was on the prompt before.
Step 7: Build and load via NETLOAD
Press F6, or go to Build → Build Solution.
Watch the Output panel at the bottom of Visual Studio. After a few seconds it should say:
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
If it says anything else, jump to the next section. If it succeeded, your compiled plugin is at:
C:\dev\HelloAutoCAD\HelloAutoCAD\bin\Debug\HelloAutoCAD.dll
Open AutoCAD with any drawing. At the command prompt, type NETLOAD and press Enter. A file picker opens. Navigate to the path above, select HelloAutoCAD.dll, and click Open.
AutoCAD gives no confirmation message when NETLOAD succeeds. Silence is success. If it failed, it will show an error.
Type HELLOSOLAR and press Enter.
You should see this in the command line:
Hello from a .NET plugin. AutoLISP, eat your heart out.
That's your first .NET AutoCAD plugin. Everything that comes after this — file dialogs, palettes, Excel parsing, HTTP calls — is built on exactly this foundation.
The errors you're going to hit
"Class Library (.NET Framework)" doesn't appear in the New Project dialog. You didn't install the .NET desktop development workload. Close Visual Studio, open the Visual Studio Installer from the Start menu, click Modify on your Visual Studio installation, check ".NET desktop development," and install it.
"Could not load file or assembly 'acmgd'" when you NETLOAD. Copy Local is set to True on one or both AutoCAD references. In Solution Explorer, click each AutoCAD reference, open the Properties panel (F4), set Copy Local to False, rebuild.
"Method not found" when you run the command. The .dll compiled against a newer .NET Framework version than AutoCAD supports. Right-click your project in Solution Explorer, choose Properties, find Target Framework, and change it to match the table: 4.8 for AutoCAD 2021+, 4.7 for 2019–2020. Rebuild.
NETLOAD appears to succeed but the command doesn't exist. AutoCAD loaded the .dll but found no registered commands. The most common cause: the [assembly: CommandClass(...)] line is inside the namespace block instead of outside it. It must appear before the namespace declaration. Check the file against the example above exactly.
HELLOSOLAR causes an unhandled exception in AutoCAD. Almost always Copy Local. See the second item above.
Visual Studio crashes immediately after installing. Reboot. This is a known Windows installer behavior when certain runtime components need a restart to finish registering. Reboot and relaunch.
Where to go next
-
C# for AutoLISP Programmers: The 10 Concepts That Translate — takes the LISP idioms you already know and maps them directly to C# equivalents: variables, loops, conditionals, functions, scope. You don't need to unlearn anything, just translate. (~35 minutes)
-
AutoCAD Solar Plugin in C# with Claude (Complete Guide) — builds a real solar drafting plugin from scratch: block insertion, layer management, command-line argument handling, and a palette UI. Also covers
PackageContents.xmland the.bundlefolder layout so your.dllauto-loads when AutoCAD starts, instead of needingNETLOADevery session. This is where the Hello World scaffolding turns into production code. (~60 minutes) -
Migrating Solar AutoLISP Routines to .NET — a practical guide to porting your existing LISP routines to C# without rewriting everything at once. Covers the incremental approach: keep LISP for geometry, call C# for everything else. (~45 minutes)
If you'd rather skip straight to using a finished plugin — one that handles homerun routing, string layouts, and PDF import inside AutoCAD without writing a line of code — that's what Branch is built for. We do the drafting. You do the engineering.
- C# for AutoLISP Programmers: The 10 Concepts That Translate (and Where the Analogy Breaks)How LISP defun, setq, and lists map to C# methods, variables, and collections — translated for AutoCAD solar engineers who need to read modern .NET plugin code.C# Onramp~35 min read
- How to Write a Custom AutoCAD Solar Plugin in C# with Claude as Your Pair ProgrammerA working guide for solar engineers who want to build their own AutoCAD plugin in C# — the setup that compiles, the Transaction trap, the selection-set wall, and where Claude actually helps versus where it hallucinates LISP from 2005.Deep Dive~60 min read
- Why Your Solar AutoLISP Routines Break on AutoCAD 2024+ (And How to Migrate to .NET)AutoCAD 2024 quietly broke selection set calls that worked since 2003. Here's what changed, why (command) is 66x slower than entmake, and the migration path solar engineers actually need.Deep Dive~45 min read