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

0 Members and 1 Guest are viewing this topic.

sheldonmcc

  • Guest
Restart AutoCAD every time .DLL is recompiled
« on: April 18, 2013, 11:37:53 AM »
I use NetLoad to load my .dll in AutoCAD. If I attempt to rebuild the .dll, I must exit AutoCAD first, then re-launch it and use NetLoad again. Is there a way around this? Is there a way to debug my code using AutoCAD without having to exit and re-launch it again?

flowerrobot

  • Guest
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #1 on: April 19, 2013, 12:37:35 AM »
Visual studios supports Edit & continue for 32bit.

Other wise no.

kaefer

  • Swamp Rat
  • Posts: 572
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #2 on: April 19, 2013, 01:43:49 AM »
Is there a way to debug my code using AutoCAD without having to exit and re-launch it again?

You could try to shadow your CommandMethod by reloading from differently named assembly.

WILL HATCH

  • Bull Frog
  • Posts: 448
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #3 on: April 19, 2013, 01:26:02 PM »
if you demand load you can avoid the netload process

TheMaster

  • Guest
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #4 on: April 19, 2013, 01:35:21 PM »
if you demand load you can avoid the netload process

The problem is that you have to shut down and restart AutoCAD, you can't unload your assembly and/or recompile it while the assembly is loaded into a running copy of AutoCAD.

huiz

  • Swamp Rat
  • Posts: 834
  • Certified Prof C3D
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #5 on: April 19, 2013, 02:10:04 PM »
And for debugging you better not demand load it. Else it points to the debug version and never will load the release version.

It is possible to start AutoCAD in the debug process and you can give a parameter /b with a script file. So AutoCAD loads the script file after starting up. In that script file you put the lines NETLOAD and the file name of your dll.

That case you can stop debugging and start again without typing the NETLOAD command all the time.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

TheMaster

  • Guest
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #6 on: April 19, 2013, 02:57:52 PM »
And for debugging you better not demand load it. Else it points to the debug version and never will load the release version.

It is possible to start AutoCAD in the debug process and you can give a parameter /b with a script file. So AutoCAD loads the script file after starting up. In that script file you put the lines NETLOAD and the file name of your dll.

That case you can stop debugging and start again without typing the NETLOAD command all the time.

If he uses code that registers the app each time it's loaded, he can demand-load the debug build and to switch to the release build, he only needs to NETLOAD it once, and the registry is updated to load the release build thereafter.  That's pretty much how it works here, except that my registration code will avoid re-registering the assembly if nothing has changed.


huiz

  • Swamp Rat
  • Posts: 834
  • Certified Prof C3D
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #7 on: April 19, 2013, 03:07:58 PM »
I found a class in ADN examples that auto register the app, but I think it would not update the path if the dll file is registered yet. Personally I use this class but don't call this class if in debug mode, but on the other hand it is better to change the path if it is netloaded again. Your solution is better (but you knew that ;-) )

On the other hand, I am slightly changing my mind about auto register apps, since the new autoload system of AutoCAD also updates the registry all the time. I now register dlls when someone installs my app. Then I don't need to call the class when running.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

TheMaster

  • Guest
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #8 on: April 19, 2013, 05:32:35 PM »
I found a class in ADN examples that auto register the app, but I think it would not update the path if the dll file is registered yet. Personally I use this class but don't call this class if in debug mode, but on the other hand it is better to change the path if it is netloaded again. Your solution is better (but you knew that ;-) )

Well, it sure is better than the knock-off that Kean made a number of years back (which didn't register subsequently-added commands).

Quote
On the other hand, I am slightly changing my mind about auto register apps, since the new autoload system of AutoCAD also updates the registry all the time. I now register dlls when someone installs my app. Then I don't need to call the class when running.

Yes, the autoloader re-registers the assembly every time its loaded, and does so needlessly.

There's a very easy way to find out if an assembly has been modified or changed in any way, and my class will check to see if it has, and if not, skips the pointless re-registration.

The fact that Autodesk did it that way doesn't make it correct. Come to think of it, a few recent threads on their discussion groups seem to suggest there's other problems that seem to linger across product releases, which smells really bad.

I believe my ExtensionApplicationInfo has been posted here. If not and someone would like it, I can post it.

BlackBox

  • King Gator
  • Posts: 3745
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #9 on: April 19, 2013, 06:59:32 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.

I'd have to test Registry Loader, or Autoloader to know for sure which is loaded first.

If loading your assembly is not startup sequence dependent, then either the Script (/b switch), or dropping an Acad.lsp in your ..\Debug\ folder should do the trick... Given that the FindFile() Method continues to incorrectly locate automatic loading user-defined files in Working Folder prior to SFSP.



I believe my ExtensionApplicationInfo has been posted here. If not and someone would like it, I can post it.

... another one of Tony's which I'll reference since he hasn't visited here much recently.

ExtensionApplicationInfo.zip
in this thread :
http://forums.autodesk.com/t5/NET/Netload-help/m-p/2736243/highlight/true#M20202
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3745
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #10 on: April 19, 2013, 07:04:16 PM »
I believe my ExtensionApplicationInfo has been posted here. If not and someone would like it, I can post it.

... another one of Tony's which I'll reference since he hasn't visited here much recently.

ExtensionApplicationInfo.zip
in this thread :
http://forums.autodesk.com/t5/NET/Netload-help/m-p/2736243/highlight/true#M20202

... Actually, no... That link takes you to another link for caddzone.   :-(

I did a quick Google search, and come up with similar (unsuccessful) top results... Any chance you'd post it, Tony?
"How we think determines what we do, and what we do determines what we get."

TheMaster

  • Guest
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #11 on: April 19, 2013, 07:34:06 PM »
I'm attaching the last distributed version (the current version here has way too much baggage that would have to be lobotomized before it could travel).

I've not tested this with anything later than AutoCAD 2011

TheMaster

  • Guest
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #12 on: April 19, 2013, 07:35:47 PM »
I will save you the trouble Tony,
 
 
Attached is Tony's ExtensionApplicationInfo

Thanks Jeff. I was posting at the same time as you.

You can delete that one and no one needs to diff them or check to see which is the latest.

BlackBox

  • King Gator
  • Posts: 3745
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #13 on: April 19, 2013, 07:49:14 PM »
Thanks Jeff, and Tony for the prompt response.

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

TheMaster

  • Guest
Re: Restart AutoCAD every time .DLL is recompiled
« Reply #14 on: April 20, 2013, 10:38:33 AM »
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.