Debugging C# with AutoCAD 2006

Debugging C# with AutoCAD 2006

Anonymous
Not applicable
1,613 Views
10 Replies
Message 1 of 11

Debugging C# with AutoCAD 2006

Anonymous
Not applicable
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
0 Likes
1,614 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
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
0 Likes
Message 3 of 11

Anonymous
Not applicable
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"
0 Likes
Message 4 of 11

Anonymous
Not applicable
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"
0 Likes
Message 5 of 11

Anonymous
Not applicable
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
0 Likes
Message 6 of 11

Anonymous
Not applicable
worked great, thanks!
0 Likes
Message 7 of 11

Anonymous
Not applicable
Then set 'startin' to your debug directory, and have an acaddoc.lsp in this
director to netload your app and anything else you need
0 Likes
Message 8 of 11

Anonymous
Not applicable
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!
0 Likes
Message 9 of 11

cgay
Enthusiast
Enthusiast
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
0 Likes
Message 10 of 11

Anonymous
Not applicable
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.
0 Likes
Message 11 of 11

Anonymous
Not applicable
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.
0 Likes