.NET

.NET

Reply
Post 1 of 15

Problems with the dotNET wizard - references and breakpoints

524 Views, 14 Replies
06-17-2012 10:55 AM

I recently installed the latest Autocad .NET Wizards, hoping that I would finally be able to debug my plugin.  I've been developing with ObjectARX for over a year now.  All previous attempts to get the debugger working on my DLL failed and I gave up.

 

The latest wizard installed OK, but when I followed the example, trouble started when I simply saved the project.  Most of the ObjectARX symbols showed red (undefined) until I added references to "Autodesk.AutoCAD.Interop" and "Autodesk.AutoCAD.Interop.Common".  These are both in C:\ObjectARX 2011\inc-x64\  The errors went away after adding these two references, but the question remains as to why this was necessary since the wizard should work out of the box as shown in the demos.

 

After staring debug (F5), AutoCAD starts and I NETLOAD my DLL.  My plugin comes up fine, but breakpoints are ignored     :-(

 

I tried some of the solutions on Through the Interface and elsewhere to no avail.  Hoping I don't have to give up again :-(

 

I'm on 64-bit Windows 7, Visual Studio 2010 Pro (4.0.30319) and AutoCAD 2011.  I'm developing in Visual Basic.

 

Gary

Post 2 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 08:27 AM in reply to: ghethco

Try creating a blank new project and check the references. Are they included? What files do they actually point to?

Ed
Post 3 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 09:44 AM in reply to: ghethco

Hello and thanks for responding.

 

Yes, I tried just a bare plugin using the wizard supplied template.  I'm assuming that's what you mean.  That is how I saw the problems I originally described.

 

It had only the default ObjecARX references defined:

  AcDbMgd.dll  (C:\ObjectARX 2011\inc\AcDbMgd.dll)

  AcMgd.dll  (C:\ObjectARX 2011\inc\AcMgd.dll)

the only other non-standard references inserted by the wizard were:

  C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll

  C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll

 

Thanks for helping out, really appreciate it.  I can't be the only one to have seen this.   I spent quite some time searching the forums though, before posting and didn't see anything applicable.

 

Gary

Post 4 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 09:53 AM in reply to: ghethco

Yes, but you mentioned that you made changes. The questions I asked required specific information. If you look at the properties for those references it will tell you where the file was actually found (or an exclamation mark if not found).

 

Also, if all you did was add the interop's, those are not adde by default. Those are only needed if you are using COM objects. Perhaps you are converting some existing vba code? When you create a new project, the dialog offers you the opportunity to add additional refrerences. You can check the appropriate boxes.

 

As far as debugging goes, do you have your project in debug mode? Run the cofig mgr (Debug>Configuration Manager) and set the solution to Debug. When you are ready to debug, run the netload the dll from the Bin/Debug folder. When you are ready to deploy, set it back to Release mode and then distribute the dll version from the Bin/Release folder.

Ed
Post 5 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 12:11 PM in reply to: Ed.Jobe

OK, sorry, misunderstood your question.  Here is a screenshot of the references after I added the following:

 

C:\ObjectARX 2011\inc-x64\Autodesk.AutoCAD.Interop.dll

C:\ObjectARX 2011\inc-x64\Autodesk.AutoCAD.Interop.Common.dll

 

 

After that all I did was add a command to test breakpoints and execute.

 

 

Gary

 

Post 6 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 12:46 PM in reply to: ghethco

So, were you able to debug?

Ed
Post 7 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 01:16 PM in reply to: Ed.Jobe

Sorry, mentioned that back in the first post.  No, breakpoints don't work so can't get into the debugger.

 

Gary

Post 8 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 01:31 PM in reply to: ghethco

I meant, after you checked your debug settings like I mentioned...assuming you did so. You didn't say what your project settings were.

Ed
Post 9 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 01:35 PM in reply to: Ed.Jobe
OK, will do so later today and let you know. Don't have the right machine in front of me. Gary -- Gary Hethcoat gary.hethcoat@gmail.com Solar PV Systems Engineer Petersen Dean Roofing & Solar http://www.petersendean.com Design4Solar http://www.design4solar.com
Post 10 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 03:18 PM in reply to: ghethco

Can you do debugging with a project not created via wizard? That is, jsut create a plain Windows class Library project and add reference to acdbmgd.dll/acmgd.dll, and write a simple command method and then run debugging. Can you do that?

 

Other things:

 

1. I never used the wizard (and do not feel I ever need it). But I can imagine the reference to COM APIs contained in Autodesk.AutoCAD.Interop and ObjectDBX Common Library is not MUST-HAVE stuff, so by default the wizard may not add reference to them. So, you may need to manaully set reference to the interop assemblies, if you HAVE TO use COM API (do not over-use/abuse them! in many cases, you do not need them, And with C# 4.0 dynamic, you can call COM API without having to have reference to COM API (equivalent to VB's late binding).

 

2. Lt looks you are targeting .NET 3.x, because reference to PresentationCode.dll 3.0. You need to verify which version of .NET of your AutoCAD 2011 uses by looking into acad.exe.config for something "<<supportedRuntime ....  V4.0.../>. If you do not see it or it is commented out, than your AutoCAD 2012 runs on .NET 3.5. Otherwise, it is on .NET 4.0. Then you make sure your project targets the same version of .NET.

 

3. When targeting .NET 4.0, there is a very annoying issue with AutoCAD using "Fiberworld". Enter "Fiberworld" at AutoCAD command line, if the value is 1, it is oftern the debugging break point would be missed when debugging. You need to enter "NextFilberworld" at command line and then set it to 0. Now you can debug, but AutoCAD's ribbon/menu/toolbar would likely stop working.

 

Post 11 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 05:06 PM in reply to: norman.yuan

Tried just starting Visual Studio, then:

  • Create a class library project (tried both .NET 4.0 and 3.5 as targets)
  • Put in the runtime references as usual, AcDbMgd & AcMgd
  • Created a simple <CommandMethod> as before
  • In Debug -> Configuration, set to "Debug" - not "Active (Debug)"
  • In Debug - Start external program: C:\Program Files\Autodesk\ACADM 2011\acad.exe
  • F5...

With both 3.5 and 4.0 targets, AutoCAD appears to be unhappy, throws an exception:

 

"Provide value on 'System.Windows.Markup.StaticExtension' threw an exception."

 

AutoCAD is frozen at this point, though it dies gracefully when I do "Stop Debugging".

 

I think I tried this before last year and also didn't have any luck.  Maybe the wizard is doing some other magic to launch AutoCAD properly?

 

I'm going to try a few other things and report back later.  Thanks for helping.  Maybe others will also find this helpful.

 

Gary

 

Highlighted
Post 12 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-18-2012 05:26 PM in reply to: norman.yuan

> 1. I never used the wizard (and do not feel I ever need it). But I can imagine the reference to COM APIs contained in Autodesk.AutoCAD.Interop and ObjectDBX Common Library is not MUST-HAVE stuff, so by default the wizard may not add reference to them.

 

I didn't add anything to the code the wizard produced other than that basic command method.  It targets .NET 3.5.

 

It had unresolved symbols marked red when I tried to save, pretty much all of them.  I did notice that the Interop references were there, but the instructions for the Wizard implied that you don't need them.  Here's what I get:

 

 

 

And...

 

 

Everything I've read and heard says to use .NET 3.5 as a target for ObjectARX.

 

When I use the checkboxs provided by the wizard for Interop, I *still* get unresolved symbols (even after saving and restarting Visual Studio and reloading the project.

 

Can't help but wonder if there's something weird about my system (?).   I'm running vanilla Win7 and Visual Studio, no special mods or anything.  Same with AutoCAD, other than the ObjectARX development I'm doing.  My plugins work fine, they just won't allow debugging.

 

Gary

 

 

Post 13 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-19-2012 04:43 AM in reply to: ghethco

OK, tried again this morning with the non-wizard method.  Last time I forgot to set CopyLocal=False on the references.  That's apparently why AutoCAD was throwing an exception.  This time the behavior was exactly like the wizard version, everything worked, just didn't stop at the breakpoint.

 

Gary

Post 14 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-19-2012 07:07 AM in reply to: ghethco

Did you do this? After acad starts, type NETLOAD, select the dll from Bin/Debug?

Ed
Post 15 of 15

Re: Problems with the dotNET wizard - references and breakpoints

06-19-2012 07:19 AM in reply to: Ed.Jobe
Yes. That much I have figured out :-)
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post