.NET

Reply
Member
neilfl
Posts: 4
Registered: ‎10-19-2012
Message 1 of 11 (586 Views)

.Net DLL Help

586 Views, 10 Replies
10-19-2012 12:35 PM

I'm trying to build an application that will write to the properties of Autodesk files. I have the iProperties for inventor files working and now I'm trying to do AutoCAD. I've found many examples of code but can't test anything because of my problems. I've seen two places to find the dll's, one is from the application directory c:\ProgFiles\AutoDesk\AutoCAD xxxx. Others are saying to download and pull from ObjectARX 2013. I get strange errors when I try and use these dll's.

 

If I use ObjectARX I get this... "Common Language Runtime detected an invalid program."

 

If I use the application directory I get this... "Could not load file or assembly 'accoremgd,..."

 

I'll be trying to do something like the following and it fails every time

 

Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

 

Here are the assemblies that I'm working with...

AcCoreMgd.dll

AcDbMgd.dll

AcMgd.dll

 

I'm clearly missing something here. Please help.

 

Thank you in advance.

 

*Expert Elite*
Alfred.NESWADBA
Posts: 9,583
Registered: ‎06-29-2007
Message 2 of 11 (572 Views)

Re: .Net DLL Help

10-19-2012 02:42 PM in reply to: neilfl

Hi,

 

what version of AutoCAD do you use?

what version of Visual Studio do you use?

what Framework have you set to your project-Framework?

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 3 of 11 (562 Views)

Re: .Net DLL Help

10-19-2012 04:34 PM in reply to: neilfl

Per chance, are you writing a extension dll for AutoCAD, or a standalone application?

 

AutoCAD's managed dlls are only usable from a .NET extension DLL that gets loaded into AutoCAD.

Member
neilfl
Posts: 4
Registered: ‎10-19-2012
Message 4 of 11 (519 Views)

Re: .Net DLL Help

10-22-2012 06:21 AM in reply to: Alfred.NESWADBA

Re: Alfred

 

AutoCAD 2013 

VS 2010 

.Net 4.0

 

Thanks,

 

Neil

Member
neilfl
Posts: 4
Registered: ‎10-19-2012
Message 5 of 11 (516 Views)

Re: .Net DLL Help

10-22-2012 06:25 AM in reply to: DiningPhilosopher

No I'm writing a standalone application.

 

I'm not sure I understand what you mean regarding the use of the DLL's, can you explain?

 

Are you saying that the DLL's cannot be consumed by a standalone application? 

 

Thanks for the help.

 

Neil

*Expert Elite*
Alfred.NESWADBA
Posts: 9,583
Registered: ‎06-29-2007
Message 6 of 11 (513 Views)

Re: .Net DLL Help

10-22-2012 06:30 AM in reply to: neilfl

Hi,

 

>> If I use ObjectARX [...]

Do you mean by this where your referenced DLL's are from? I always use the DLL's from the AutoCAD installation directory (but I know that Stephen Preston always says that the DLL's from the ObjectARX-kit should be referenced).

And just to make sure: you have downloaded the ObjectARX for AutoCAD 2013?

 


>> Could not load file or assembly 'accoremgd,...

Is it possible that you have:

  • your application on a network-drive
  • you have set "yes" to the "local copy" property of the refernces?

 

Sometimes during development I saw that cleaning the output-directory, restarting VS and fully recompile the solution was necessary to get it running again (especially if you have multiple projects open using same source(parts), ==> try that also!

 

Good luck, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
*Expert Elite*
Alfred.NESWADBA
Posts: 9,583
Registered: ‎06-29-2007
Message 7 of 11 (510 Views)

Re: .Net DLL Help

10-22-2012 06:35 AM in reply to: neilfl

Hi,

 

ok, our posts crossed :smileywink:

 

>> No I'm writing a standalone application.

you can use DLL's, of course, but only the ones that are loaded into AutoCAD can use the mananged API.

 

If you have an EXE that starts AutoCAD and than uses _NETLOAD (or something like demand-loading) to load a special DLL into AutoCAD, then it's ok for using the managed API (and referencing the *mdg.dll).

 

If you have an DLL from outside AutoCAD then you can just use the COM-objects API, not the managed one.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 8 of 11 (498 Views)

Re: .Net DLL Help

10-22-2012 08:33 AM in reply to: neilfl

neilfl wrote:

No I'm writing a standalone application.

 

Are you saying that the DLL's cannot be consumed by a standalone application? 

 


Right.

 

AutoCAD's managed DLLs are provided as managed wrappers for accessing functionality in AutoCAD. They can't be used remotely, only from extension DLLs that are loaded into AutoCAD's process.

 

The only way to interact with AutoCAD from another process is via it's ActiveX API.

 

 

Member
neilfl
Posts: 4
Registered: ‎10-19-2012
Message 9 of 11 (486 Views)

Re: .Net DLL Help

10-22-2012 11:14 AM in reply to: DiningPhilosopher

DP, where can I find documentation on using ActiveX API for AutoCAD and extension dll's from AutoCAD process?

 

 

Mentor
mzakiralam
Posts: 231
Registered: ‎11-09-2012
Message 10 of 11 (398 Views)

Re: .Net DLL Help

11-14-2012 06:12 AM in reply to: neilfl

@neilfl: You mentioned that: I've found many examples of code but can't test anything because of my problems.

 

Where did you find examples of code? Can you give me the link? I also need to practice.

 

Thanks in advance.

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.