.NET

Reply
*Homer Simpson
Message 1 of 11 (248 Views)

Debugging C# with AutoCAD 2006

248 Views, 10 Replies
07-05-2005 12:36 PM
Hi everyone,

I'm writing code in VS2005 (C#) and would like to know if there is a better
why to debug than my current method. Currently, I wrote the code and compile
in VS. Then, I start AutoCAD and use NETLOAD to load the DLL and test my
application. If I find a problem, I go back to VS, change the code,
recompile, restart AutoCAD, etc. This is, to say the least, a rather long
process when I just want to see the results of some "what if" scenarios that
are just part of the process of learning a new programming language.

1) Any suggestions for debugging inside VS with AutoCAD?
2) Can I unload .NET assemblies in AutoCAD 2006 without restarting AutoCAD?
This would save me steps / time involved with restarting AutoCAD / Civil 3D.

Thanks,
Scott
*Albert Szilvasy
Message 2 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

07-05-2005 04:01 PM in reply to: *Homer Simpson
This is the technique I use. There's nothing better. There's no way to
unload .net assemblies that are loaded.

Albert

"Homer Simpson" wrote in message
news:4893081@discussion.autodesk.com...
Hi everyone,

I'm writing code in VS2005 (C#) and would like to know if there is a better
why to debug than my current method. Currently, I wrote the code and compile
in VS. Then, I start AutoCAD and use NETLOAD to load the DLL and test my
application. If I find a problem, I go back to VS, change the code,
recompile, restart AutoCAD, etc. This is, to say the least, a rather long
process when I just want to see the results of some "what if" scenarios that
are just part of the process of learning a new programming language.

1) Any suggestions for debugging inside VS with AutoCAD?
2) Can I unload .NET assemblies in AutoCAD 2006 without restarting AutoCAD?
This would save me steps / time involved with restarting AutoCAD / Civil 3D.

Thanks,
Scott
Member
GaryPuerini
Posts: 3
Registered: ‎07-06-2005
Message 3 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

07-06-2005 05:49 AM in reply to: *Homer Simpson
The only step I was able to elimanate was manually typing the he "netLoad" command.
I did this by including a script in my ADT short cut, where in the scipt file, I used the command "_NETLOAD"
*Matthew
Message 4 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

07-06-2005 06:22 AM in reply to: *Homer Simpson
under the project properties you could eliminate the start AutoCAD step by
setting the "Start external program" to the location of autocad. this
setting is under the debugging properties in that dialog.

Matthew

wrote in message news:4893631@discussion.autodesk.com...
The only step I was able to elimanate was manually typing the he "netLoad"
command.
I did this by including a script in my ADT short cut, where in the scipt
file, I used the command "_NETLOAD"
*Matthew
Message 5 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

07-06-2005 12:17 PM in reply to: *Homer Simpson
In the Script file you could use an autolisp function. I have not tested
this but you could try it. You can use autolisp in a script file.

(command "netload" "c:/mypath/myfile.dll")

hth
Matthew

"Homer Simpson" wrote in message
news:4893081@discussion.autodesk.com...
Hi everyone,

I'm writing code in VS2005 (C#) and would like to know if there is a better
why to debug than my current method. Currently, I wrote the code and compile
in VS. Then, I start AutoCAD and use NETLOAD to load the DLL and test my
application. If I find a problem, I go back to VS, change the code,
recompile, restart AutoCAD, etc. This is, to say the least, a rather long
process when I just want to see the results of some "what if" scenarios that
are just part of the process of learning a new programming language.

1) Any suggestions for debugging inside VS with AutoCAD?
2) Can I unload .NET assemblies in AutoCAD 2006 without restarting AutoCAD?
This would save me steps / time involved with restarting AutoCAD / Civil 3D.

Thanks,
Scott
Member
GaryPuerini
Posts: 3
Registered: ‎07-06-2005
Message 6 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

07-07-2005 07:30 AM in reply to: *Homer Simpson
worked great, thanks!
*Mark Gardiner
Message 7 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

07-18-2005 06:27 PM in reply to: *Homer Simpson
Then set 'startin' to your debug directory, and have an acaddoc.lsp in this
director to netload your app and anything else you need
New Member
ShareRain
Posts: 1
Registered: ‎12-11-2005
Message 8 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

12-11-2005 02:36 AM in reply to: *Homer Simpson
How about using assemblies late binding method. You create a loader class and binding your object class into AutoCAD. I'm just thinking, haven't try. Hope it works!
Distinguished Contributor
cgay
Posts: 125
Registered: ‎08-02-2005
Message 9 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

12-12-2005 07:05 AM in reply to: *Homer Simpson
Here is the method I use.

1.) I create an AutoCAD Script File in my programs source directory.
(i.e. "C:\Projects\TestProj\Load.scr")

2.) I open this file in notepad and add the text to load the dll.
(i.e. _netload C:\Projects\TestProj\bin\TestProj.dll)

3.) In the "Configuration Properties" section of the projects Property Pages, I change the "Start Action" to "Start External Program" and add path to AutoCAD exe, then add the "Command Line arguments" to load the script file.
(i.e. /nologo /b "C:\Projects\TestProj\Load.scr")

This seems to work well for me. You could also add the name of a drawing to open so you don't have to open one up each time you debug.
(i.e. "C:\Drawings\Test.dwg" /nologo /b "C:\Projects\TestProj\Load.scr")

Note that I add the /nologo switch, which seems to load AutoCAD faster.

There are several other command line switches for AutoCAD. Find them in the AutoCAD Help Files, search for "Customize Startup - Concepts".

Good Luck,
C Message was edited by: CougerAC
Valued Contributor
rtejada
Posts: 61
Registered: ‎06-19-2002
Message 10 of 11 (248 Views)

Re: Debugging C# with AutoCAD 2006

02-07-2006 08:37 AM in reply to: *Homer Simpson
Yes, it worked, I manage to add your code, and it is now working fine.

I look that I was missing the CommandFlags.Session part. I was wondering what does it do.

Thanks you very much Couger and Tony.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.