Most of our desktop products support a "plug-in" model of development: you create a DLL (which may or may not be renamed with a number of extensions, such as DBX or ARX) which gets loaded into the calling executable's memory space. This allows the process to share memory with the loaded modules, improving performance over the more archaic IPC (inter-process communication)-based architectures.
[Here begins retracted information...]
While Visual C++ Express Edition supports debugging DLL projects using an external executable, Visual C# Express and Visual VB.NET Express Editions do not. When developing with our products it is extremely common to launch an external executable (for instance AutoCAD's executable, acad.exe), which in turn loads your class module/DLL into its memory space, allowing you to step through the code, watching the contents of variables and all the good stuff that comes with a professional debugging tool.
This essentially means these two tools (Visual C#/VB.NET Express Editions) are crippled when it comes to doing serious development work with a plug-in architecture such as AutoCAD's. Visual C++ Express Edition, on the other hand, apparently allows you to debug DLL projects fully.
[End of retracted information.]
OK - I'm adding some information to this post... the paragraphs above belonged to my initial post, and aren't strictly true. Thanks to Ray Mendoza for raising this issue.
While Visual Basic 2005 (and presumably Visual C#) Express Edition does not make it easy for you to set up and use an external application to debug a class library, it is possible to do. Here's the initial message you get, when you simply try to debug a class library with no addition project set-up performed:
While at first you think "OK, great - let me just add in acad.exe and have it as the startup object", when you come to modify the project settings, there's no easy way to do it. You may be able to add in a separate EXE project to debug, but we don't have or need that for a pre-built EXE such as AutoCAD.
So what can we do? Well, it turns out that all you need to enable debugging in Visual Basic Express Edition is a separate file in the project folder, called "MyProjectName.vbproj.user". This contains the user-specific project settings for the MyProjectName project. In my test I used the default project name for a Class Library, and so the file was called "ClassLibrary1.vbproj.user" and in the same folder as "ClassLibrary1.vbproj". Here are the contents of that file:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files\AutoCAD 2007\acad.exe</StartProgram>
</PropertyGroup>
</Project>
After creating this file (please make sure the executable path is correct for your system, of course), you will need to reopen the project for it to be detected and read. But once it's found, you can debug your class library project with an external executable, just by hitting F5. Once AutoCAD is loaded, NETLOAD your DLL and away you go.
This file does get created automatically using the Autodesk Managed AppWizard (part of the ObjectARX Wizard - see the previous post for more information).
Now - if someone out there knows an easier way to set this up directly in VB Express, please do let me know, by email or by adding a comment to this post. This is the first time I've used VB Express myself, so there may well be something obvious that I've missed.


Subscribe via RSS
I use VB .Net Express to create cutom functions in AutoCAD...I have had no problem getting VB Express to debug...I have to tell it to startup AutoCAD and I also have to netload the dll that I am creating...I get the "do not use managed code..." error a few times, but everything runs well after that...
Posted by: Ray Mendoza | July 06, 2006 at 10:55 PM
Thanks for the update..Thought it was just me.:)
Posted by: Paul Richardson | July 08, 2006 at 12:23 AM
Thanks very much did the trick also had to set the working directory to same location as exe to avoid a subsequent error.
Posted by: Ian | November 08, 2006 at 11:38 PM
Hello, all. Those who attended my classes last year at AU (AU 2006) received a DVD that included a Template for creating VB.NET applications using VB.NET Express. I have since created templates that can be used for creating Jigs (both Draw and Entity Jigs) using VB.NET Express Edition. Look me up this year if you would like these templates.
By the way, nearly all of my classes use VB.NET Express edition - even the Hands-On Introduction to VB.NET Labs.
Take care and I hope to see you at AU 2007.
Jerry Winters
Posted by: Jerry Winters | October 12, 2007 at 05:41 AM
Thanks, Jerry.
Looking forward to seeing you in Vegas!
Kean
Posted by: Kean | October 12, 2007 at 09:30 AM
Now that VS 2008 is out, does the first line of the above file need to change?
Posted by: David Hall | November 22, 2007 at 04:29 PM
It's possible - I won't have time to research whether the information provided is still relevant in the 2008 Express Editions for some time.
If someone researches this and finds out what changes are needed (if any), please post the information as a comment.
Kean
Posted by: Kean | November 22, 2007 at 04:33 PM
I tried this same thing with the C# Express Edition 2008 and it worked just fine without any alterations.
Posted by: Anthony | December 21, 2007 at 07:01 PM
Is anyone getting a LoaderLock Error when they start debugging?
Posted by: Mark L | June 28, 2008 at 09:03 AM
I am using VB.net Express 2008
Below The LoaderLock Error, I am getting this error:
I'm not how to fix it???
Any ideas?
Thanks
Mark
DLL 'C:\Program Files\Autodesk Land Desktop 2006\FdoConfigUi.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
Posted by: Mark L | June 28, 2008 at 09:11 AM
Hi Mark,
Sorry - I don't use Land Desktop, so don't see this error.
Is this something you can disable in Debug -> Exceptions... ?
Regards,
Kean
Posted by: Kean | July 07, 2008 at 12:05 PM
Seems to work just fine in Express 2008. The vbproj.user file already existed in my project with the exact same first line so I just replaced it. Pointed it at the AutoCAD 2008 executable and finally I can netload & debug.
Thanks
Posted by: John | September 06, 2008 at 11:22 PM
Hi, Mark
i am using VS Express(VC,VCS,VB) , i have a problem that i can not build object arx in VC because have link to ATL or MFC, can i do without ATL/MFC?
Posted by: heru h day | September 19, 2008 at 09:02 AM
for LoaderLock Error you can unactive "Loader Lock" by:
Hit CTRL+Alt+E (mnu debug/exceptions)
In managing debbug...
uncheck loaderlock
Posted by: Ivan | December 23, 2008 at 02:01 PM
Hi!
I tried this with Visual C# 2008 Express, and it works, too. You've just got to name the extra file "MyProjectName.csproj.user".
Thanks a lot to the author - you saved me a lot of hassle =)
Posted by: MEDooSA | January 21, 2009 at 02:56 PM
I'm using Visual Basic 2008 Express Edition.
I tried and it was really helpful.
Thanks.
Posted by: Oscar Quintero | April 03, 2009 at 01:41 AM
Hi!
If you also would like to automaticly netload your dll in Autocad from Visual Basic 2008 .NET then do the following:
- create a text file in notepad
- type in : netload ..\bin\Debug\[myclass].dll
- save the file in you vb project directory as "script.scr"
- in the vb.net IDE go to you project properties => debug => and type in the 'command line arguments' /b "[path to vb.net project]\script.scr"
- if you debug your project then the DLL in the debug directory will be netloaded.
Posted by: Ferry Kranenburg | April 03, 2009 at 10:13 AM
I am using visual studio C# 2008 express but do not see the .csproj.user file only the .csproj file. Am I missing a step?
Posted by: aok | April 27, 2009 at 01:53 AM
aok -
If I recall correctly, the point is that you need to create the .csproj.user file yourself.
Regards,
Kean
Posted by: Kean Walmsley | April 28, 2009 at 01:40 PM