.NET

.NET

Reply
Active Contributor
110000474593
Posts: 29
Registered: ‎09-24-2012
Message 1 of 7 (1,754 Views)
Accepted Solution

Can't debug anymore with VS2010 or VS2012 and Acad 2009

1754 Views, 6 Replies
01-07-2013 11:11 PM

Hello,

 

I have problems with debugging my .NET application which I use in Autocad Electrical 2009. Here is the problem:

 

1. A few weeks ago, I created a .dll file, written in C# in VS2010 (Visual Studio). Everything worked, also debugging (Debug options -> Start external program -> acad.exe).

2. Now, I want to add some code to this .dll file, so I opened the project in VS2012. I added the code and I want to debug. But, when I 'netload' my .dll file in autocad and type my command (defined in my code with 'CommandMethod'), Autocad says "Uknown command".

3. Then I tried another way. I started Autocad the 'normal' way (not from visual studio), netload my .dll file and typed the command and..: It works!!. After that, I attached my VS project to the acad.exe process, typed my command and.. Autocad froze. So, that isn't working either.

 

It looks like my .dll file is working, but not when I attach VS to Autocad or when I start Autocad through VS.

So, after that, I created a very small program in VS2010 (new project) which only shows a messagebox that says: "Hello Autocad". I started up Autocad the normal way, typed the method and it works. Debugging, not working. The same story when I create the same little program in VS2012.

 

I read about changing the "acad.exe.config", changing the debugger type and so on, but nothing helps. Can anyone tell me why I can't debug anymore and how to solve this problem?

 

Maybe the problem is already solved in this discussion by JamieVJohnson2, but what does he mean with the following:

 

"What I would do...  I would run ACAD normally, and then force load the dll manually (NETLOAD command).  If that is working ok, then I would check the registry entry to see if it is properly mapped for the CURRENT user.  Yep it can be different for every user.

 

If you didn't make it past the first idea, then possibly the dll, is trying to copy to source the acad dlls (bad mojo), and that causes the Netloading process to abort."

 

 

I hope someone can help me.

 

Kind regards

6. Directory bin\Debug must not contain files acmgd.dll acdbmgd.dll accoremgd.dll 

If it contain those files - delete them.

*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 2 of 7 (1,722 Views)

Re: Can't debug anymore with VS2010 or VS2012 and Acad 2009

01-08-2013 01:16 PM in reply to: 110000474593

Which version of .NET framework your VS2012 project is set to target? For Acad2009, it must be .NET2.0/3.x.

 

I still have Acad2009 installed, along with Acad2012. I have no problem to create a simple "Hello AutoCAD" project in VS2012, targeting .NET 3.5 and do debugging run from VS2012, that is:

 

1. Press F5 in VS2012 to start external app (acad.exe);

2. Netload the DLL;

3. enter command;

4. Beak point set in VS2012 is hit;

5, Step through as needed.

 

So, make sure you target your VS2012 to correct .NET version (2.0/3.x, no 4.x!); and also make sure "Copy Local" to false with the references acad assemblies

Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 3 of 7 (1,717 Views)

Re: Can't debug anymore with VS2010 or VS2012 and Acad 2009

01-08-2013 01:49 PM in reply to: norman.yuan

6. Directory bin\Debug must not contain files acmgd.dll acdbmgd.dll accoremgd.dll 

If it contain those files - delete them.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Contributor
110000474593
Posts: 29
Registered: ‎09-24-2012
Message 4 of 7 (1,699 Views)

Re: Can't debug anymore with VS2010 or VS2012 and Acad 2009

01-09-2013 01:31 AM in reply to: norman.yuan

The project is set to framework 3.5. It's so weird, everything worked a few weeks ago and now it doesn't work anymore and I changed nothing as far as I know.

 

"Copy local" was set to "true" for every acad assembly and as I said, a few weeks ago with VS2010 it worked. (AcDbMgd, AcMgd and the interop and interop.common references). Now I've changed it back to "false" and acad recognized my command, but my breakpoints won't hit. So it doesn't work completely yet.

 

I thought the AcDbMgd and AcMgd references must be copied to local? I've seen that in a video of Acad where they explain how to convert a VB program to a C# .dll.

Active Contributor
110000474593
Posts: 29
Registered: ‎09-24-2012
Message 5 of 7 (1,692 Views)

Re: Can't debug anymore with VS2010 or VS2012 and Acad 2009

01-09-2013 02:44 AM in reply to: 110000474593

Update: Debugging is working with VS2010

Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 6 of 7 (1,688 Views)

Re: Can't debug anymore with VS2010 or VS2012 and Acad 2009

01-09-2013 03:47 AM in reply to: 110000474593

110000474593 wrote:

I thought the AcDbMgd and AcMgd references must be copied to local?


No!!! Copy Local == False is an indispensable condition of normal operation and debugging.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Contributor
DouceDeux
Posts: 47
Registered: ‎09-04-2012
Message 7 of 7 (1,680 Views)

Re: Can't debug anymore with VS2010 or VS2012 and Acad 2009

01-09-2013 05:17 AM in reply to: 110000474593

I would say first, create a brand new solution and a project of the same type you're having problems with debug.

Now try with some basic code and see if breakpoints will be hit with that new solution or other solutions you may have. If breakpoints are not hit then it's probably debugging option that is messing with you.

I had this problem and while trying to fix it I rendered my dev computer useless bc it didnt have any other framework but 4.0 and it wouldn't let you install 3.5 or below because the OS would say it's already installed. Weird stuff!

 

Edit: About your last question in the firest post, it might have to do with plugin keys at

HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.0\ACAD-8001:409\Applications

which is where your plugins should be registered, but if you haven't done it manually, it shouldn't even be registered there for load, automatic or otherwise. Not sure what he meant either.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.