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

Debug using Visual Studio Express 2013 and AutoCad 2010/2014

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
wbdehaan
3697 Views, 17 Replies

Debug using Visual Studio Express 2013 and AutoCad 2010/2014

Hi, 

 

With Visual Studio Express 2013 i'm trying to debug AutoCad2010, but it refuses to break the operation, Is it possible to debug AutoCad 2010 with VSE2013? I am using framework 3.5, because AutoCad 2010 doesn't work with 4.5

 

I have created multiple projects in VSE2008 with AutoCad 2010. That worked fine..

 

kind regards, 

 

Wouter

17 REPLIES 17
Message 2 of 18
Alfred.NESWADBA
in reply to: wbdehaan

Hi,

 

>> i'm trying to debug AutoCad2010, but it refuses to break the operation

How does that "break the operation" look like? Do you get any messages or what happens?

At least yes, the combination of VS2013 Prof. and debug AutoCAD 2010 works well, and so I guess that the Express version does work too.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 18
wbdehaan
in reply to: wbdehaan

Hi Alfred,

 

thank you for your reply!

 

I will try to explain what i did. first I created a new project, added acdbmgd.dll and acmgd.dll, (with properties copy local: false)

then changed the testproject.vbproj file, and added 2 lines, because this option is not available in the Express edition to start AutoCad:

 

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <StartAction>Program</StartAction>
    <StartProgram>C:\Program Files (x86)\AutoCAD 2010\acad.exe</StartProgram>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <OutputPath>bin\Debug\</OutputPath>
    <DocumentationFile>testproject.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>

 

then added some simple code in class1.vb

 

Imports Autodesk.AutoCAD.Runtime

Public Module testModule
    <CommandMethod("testprog")> Sub main()

        Dim TempText As String = "Hello World"
        MsgBox(TempText)

    End Sub
End Module

- pressed 'Start- '-button in VBE: with options on the right of start-button: Debug & Any CPU

- after that AutoCad started automatically, 

- in AutoCad I typed netload, and loaded the dll from the \bin\debug\testproject.dll

- when I type 'testprog' in the command-line of AutoCad, the program is started, and gives me 'hello World'-msgbox.

 

but when I press 'Pause'-button in VBE2013, to debug my code, I get this message:

 

 

error.png

 

 

I tried the option: use managed compatibility mode in Tools > Options

debug.png

 

and also Enable native code debugging, but it doesn't work

 

debug2.png

 

I Use a 64bit machine with Windows 7, Visual Studio Express 2013, and AutoCad 2010* and AutoCad2014

(* My collegues use AutoCad2010, because I have to rewrite tons of VBA-code)

 

Hope I explained enough, awaiting your answer,

 

kind regards, 

 

Wouter de Haan

the Netherlands

 

 

Message 4 of 18
Alfred.NESWADBA
in reply to: wbdehaan

Hi,

 

your path points to AutoCAD 2010 in the x86-programs path, is that really correct (as you are working on a 64bit system)?

 

>> but when I press 'Pause'-button in VBE2013, to debug my code

Do you press "pause" when the MsgBox is open or later?

What happens if you set a breakpoint at the line where you calling the MsgBox and start then the command?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 18
wbdehaan
in reply to: Alfred.NESWADBA

Hi Alfred

 

AutoCad2010 is installed as 32bit version, to be able to use VBA, so yes this is correct. VBE starts AutoCad correctly..

 

kind regards

 

Wouter

Message 6 of 18
Hallex
in reply to: wbdehaan

Wouter, try add reference to accoremgd.dll, then app run again
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 7 of 18
wbdehaan
in reply to: Hallex

Hi Alfred, 

 

thanks for your assistance, but unfortunately it doesn't work. I added the accoremgd.dll from AutoCad 2014 and added this reference to the project (set copy local false), and then I got 50 errors about the framework incompatability using 3.5 instead of higher. And <CommandMethod("Testprog"> became ambiguous in the autodesk.autocad.runtime namespace.

 

Is it better to downgrade visual studio to 2012 or maybe 2008 again? Or should it be able to work with debugging?

 

kind regards, Wouter

Message 8 of 18
Hallex
in reply to: wbdehaan

Wouter,
Try to rebuild a project using 4.0 Net.Framework
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 9 of 18
Alfred.NESWADBA
in reply to: wbdehaan

Hi,

 

accoremgd.dll is only correct for AutoCAD 2013 or 2014, not for AutoCAD 2010.

My question is now: how did you install the 32bit-version of AutoCAD onto your 64bit operating system? Are you using any virtual pc or something similar?

 

>> Is it better to downgrade visual studio to 2012

At least I don't think that this is necessary, the source or the problem is imho not depending on VS2012 or VS2013.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 10 of 18
wbdehaan
in reply to: Alfred.NESWADBA

Hi Alfred & Hallex,  

 

our system-adminstrator installed it using a tool, that makes it possible to install it as 32-bit, because in the 64bit version there is no VBA-support anymore. Therefore it's installed in the program files (x86) directory. 

 

@Hallex : I also tried compiling using framework 4.0 and 4.5, but no success

 

Kind regards,

 

Wouter

Message 11 of 18
Alfred.NESWADBA
in reply to: wbdehaan

Hi,

 

may I come back to  that question from post 4 in this thread?

>> What happens if you set a breakpoint at the line where you calling the MsgBox and start then the command?

Does it stop or does it ignore the breakpoint?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 12 of 18
wbdehaan
in reply to: Alfred.NESWADBA

Hi Alfred, 

 

it ignores the breakpoint completely.

f.y.i.: It starts the correct (debug)-dll, because when I stop the running project and change the text in the messagebox and rerun the netload command in AutoCad, it shows the change in text, therefore i'm sure it's not loading a different dll.

 

kind regards, Wouter

Message 13 of 18
Alfred.NESWADBA
in reply to: wbdehaan

Hi,

 

I'm sorry not to have any more ideas what I can do from the distance.

Maybe playing with the ACAD.EXE.CONFIG might be a help, but I have not the environment with a ACAD2010x32 installed on a 64bit OD. The only thing I can say is that development/debugging in Win7x64 with VS2013 and Civil3D2010 (which is 32bit as there was no 64bit version availaible) does work well.

 

Sorry, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 14 of 18
wbdehaan
in reply to: Alfred.NESWADBA

Hi Alfred, 

 

thanks for your effort, I will try to install a previous version of VBE (because debugging Autocad2010 with VBE 2008 worked well), or maybe try the installation on a different computer)

 

kind regards, Wouter

Message 15 of 18
wbdehaan
in reply to: wbdehaan

Hi Alfred, 

 

When I use autoCad 2014 (64bit installed on 64Bit machine) and VBE 2013, i'm still not able to debug...and it seems like the project isn't loaded, when I use netload in AutoCad.

 

tried:

- http://through-the-interface.typepad.com/through_the_interface/2013/11/debugging-autocad-using-visua...

  1. Turn on “Use Managed Compatibility Mode” via Tools –> Options –> Debugging.
  2. Turn on “Enable native code debugging” from Project –> Properties –> Debug.

 

also tried:

- Loading accoremgd.dll, then it gives lot's of warnings:

Warning 1 The primary reference "accoremgd" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework. testproject

> tried rebuilding project:

 

maybe there's a solution to this, and otherwise i'll ask the system operator for installing an older version of VBE, 2012 or maybe back to the working 2008 version. Thanx in advance,

 

kind regards, Wouter

Message 16 of 18
Alfred.NESWADBA
in reply to: wbdehaan

Hi,

 

can you upload a (small) sample project?

I try to start this on my system, do the corrections, if necessary, and send it back ... for you to try.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 17 of 18
wbdehaan
in reply to: Alfred.NESWADBA

Hi Alfred,

 

in this mail there is an attachment with a small "hello world"-msgbox project 

 

When I netload this project (the debug-version), it first gives me a warning about not trusted* project, I choose Load

* added d:\vbet\ to my trustedpaths, but seems like it doesn't read the subdir's inside, so i added the complete path to the dll, that works)

 

security.png

 

then it doesn't start the program, like it does on AutoCad2010. 

 

unknown.png

 

---

 

 

below the added code in de class1.vb, with a breakpoint on 'Dim Temptext ..'

Imports Autodesk.AutoCAD.Runtime

Public Module testModule
    <CommandMethod("testprog")> Public Sub main()
        Dim TempText As String = "Hello World"
        MsgBox(TempText)
    End Sub
End Module

For your information:

- Menu Tools > Options > Debugging > Use Managed Compatibility mode = checked

- Solution Explorer > My Project > Menu Debug > checkbox Enable native code debugging = unchecked

Solution Explorer > My Project > Menu References > add dll Microsoft ActiveX Data Objects 6.1, because of future connection with SQL-server, is not neccessary at this moment,

 

kind regards

 

Wouter

 

 

 

 

Message 18 of 18
wbdehaan
in reply to: wbdehaan

Hi Alfred,

 

finally i found a solution. I downgraded my Visual Basic Express 2013 to Visual Basic Express 2010, and still debugging didn't work at begin. Then I found a solution from Kean Walmsley:

 

http://through-the-interface.typepad.com/through_the_interface/2010/04/hitting-breakpoints-in-net-cl...

 

and used solution 2:

 

"The cause of the problem boils down to the fact that VS 2010 does not choose the right version of the debugger for Class Library projects targeting prior versions of the .NET Framework: it always uses the default version, the debugger targeting v4 of the .NET Framework. This debugger doesn’t see breakpoints in projects targeting older versions of .NET."

 

Solution 2

Modify the config file of the exe that loads your AddIn (acad.exe.config, revit.exe.config, etc) so that it contains the following just before the 

</configuration> 
<startup>
  <supportedRuntime version="v2.0.50727" />
</startup>

 

 

 

that worked! Now I can try to do the same when using VBE2013.

 

Using AutoCad 2010 (installed as 32bit on a 64bit machine, using Windows 7)

 

thanks for all your effort!

 

kind regards

 

Wouter

 

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