Author Topic: Restart AutoCAD every time .DLL is recompiled  (Read 21328 times)

0 Members and 1 Guest are viewing this topic.


  • King Gator
  • Posts: 3770
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #15 on: April 20, 2013, 01:21:40 PM »
Methinks 'the best way' of loading one's assembly should depend on the nature of the code... You don't want to NETLOAD an assembly that hooks RibbonServices.RibbonPaletteSetCreated Event to fully initialize, as by the time you're able to enter NETLOAD that event has already come and gone.

There seems to be a lot of confusion about ribbon initialization.  It's pretty simple, and you don't have to concern yourself with how/when your app is loaded.

If when your app is loaded, the ribbon exists, then you add a handler to the Application.Idle event, and the first time the event fires, you remove the Idle event handler so it doesn't fire again, and you initialize your ribbon components.

If upon loading of your app the ribbon doesn't exist, then you hook the RibbonPalleteSetCreated event. If/when that event fires, you add a handler to the Application.Idle event, and when that event fires, remove that handler from the Idle event and initialize your ribbon components.

So, in all cases, you are doing initialization in a handler for the Idle event, and the only question is when to add the Idle event handler, which depends on whether the ribbon exists when your app is loaded.

I haven't seen a case where that fails, including when the ribbon exists but is not visible. If there is some issue with the initializing your ribbon components when the ribbon isn't visible, I'd like to know about it, as that would seem to be the only possible gotcha in this case.

Given the tangential nature of the topic of CUIx, I've responded to your post in my topic-specific thread here, Tony

"How we think determines what we do, and what we do determines what we get."


  • Bull Frog
  • Posts: 342
  • Crash Test Dummy
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #16 on: April 23, 2013, 05:21:40 AM »
either the Script (/b switch), or dropping an Acad.lsp in your ..\Debug\ folder should do the trick...

I just drop this snippet into my whatever.csproj.user file (or create it if it doesn't exist), obviously with the folder name edited, and it starts & Netloads AutoCAD whenver I hit F5 on a v2013 project (2013 is what's on my dev laptop). A Visual Studio project template won't automatically create it without resorting to a wizard, unfortunately.

Code - XML: [Select]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Project ToolsVersion="4.0" xmlns="">
  3.   <PropertyGroup Condition=" $(DefineConstants.Contains('2013')) ">
  4.     <StartAction>Program</StartAction>
  5.     <StartProgram>C:\Program Files\Autodesk\AutoCAD 2013\acad.exe</StartProgram>
  6.     <StartArguments>/b "...path to project files .....\NetLoadScripts\AutoNetLoadDebug.scr"</StartArguments>
  7.   </PropertyGroup>
  8. </Project>

... or you could just fill it in using the project properties window as per the screengrab attached.

My netload script (from my Project template) only has this in it ...
Code: [Select]
netload "C:\---Path to Codez---\$projectname$\$projectname$\bin\Debug\ACAD2013\$projectname$Acad2013.dll"
Note you need a new-line at the end of the .scr file.
« Last Edit: May 17, 2013, 08:17:38 AM by CADbloke »

  • Mosquito
  • Posts: 6
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #17 on: January 29, 2022, 09:46:12 PM »
I recently built a solution that allows reloading the same copy of a .dll into AutoCAD.
This way developers can test their changes without closing and restarting AutoCAD.

Check out my blog with the full solution:

  • Mosquito
  • Posts: 6
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #18 on: August 12, 2022, 03:08:12 PM »
I recently released cadwiki's first nuget package with a package that allows AutoCAD developers to reload dll's

blog post

example repo

nuget package