• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Member
    Posts: 4
    Registered: ‎10-19-2012

    .Net DLL Help

    412 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.

     

    Please use plain text.
    *Expert Elite*
    Posts: 6,641
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.
    Valued Mentor
    Posts: 342
    Registered: ‎05-06-2012

    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.

    Please use plain text.
    Member
    Posts: 4
    Registered: ‎10-19-2012

    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

    Please use plain text.
    Member
    Posts: 4
    Registered: ‎10-19-2012

    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

    Please use plain text.
    *Expert Elite*
    Posts: 6,641
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.
    *Expert Elite*
    Posts: 6,641
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.
    Valued Mentor
    Posts: 342
    Registered: ‎05-06-2012

    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.

     

     

    Please use plain text.
    Member
    Posts: 4
    Registered: ‎10-19-2012

    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?

     

     

    Please use plain text.
    Valued Contributor
    mzakiralam
    Posts: 54
    Registered: ‎11-09-2012

    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.

    Please use plain text.