.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with the dotNET wizard - references and breakpoints

14 REPLIES 14
Reply
Message 1 of 15
ghethco
808 Views, 14 Replies

Problems with the dotNET wizard - references and breakpoints

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

14 REPLIES 14
Message 2 of 15
Ed.Jobe
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

EESignature

Message 3 of 15
ghethco
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

Message 4 of 15
Ed.Jobe
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

EESignature

Message 5 of 15
ghethco
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

 

Refs.jpg

 

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

 

NewCode.jpg

 

Gary

 

Message 6 of 15
Ed.Jobe
in reply to: ghethco

So, were you able to debug?

Ed

EESignature

Message 7 of 15
ghethco
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

Message 8 of 15
Ed.Jobe
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

EESignature

Message 9 of 15
ghethco
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
Message 10 of 15
norman.yuan
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.

 

Message 11 of 15
ghethco
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

 

Message 12 of 15
ghethco
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:

 

 

Acad01.jpg

 

And...

 

Acad02.jpg

 

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

 

 

Message 13 of 15
ghethco
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

Message 14 of 15
Ed.Jobe
in reply to: ghethco

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

Ed

EESignature

Message 15 of 15
ghethco
in reply to: Ed.Jobe

Yes. That much I have figured out 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost