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

    Autodesk ObjectARX

    Reply
    Active Member
    Posts: 8
    Registered: ‎08-07-2009
    Accepted Solution

    How to load a Managed dll from an arx file?

    246 Views, 5 Replies
    05-03-2012 11:33 PM

    Greetings,

    Recently I had to add some features available only in .NET, to the project I developed using ObjectArx. I created a Managed dll using C#, and I want to load that dll when my main arx dll is loaded. I do not want to demand-load that dll by adding some registry keys.

    As I found the command of "acrxDynamicLinker->loadModule()" does not work for managed dlls. I am wondering if there is another command or method to load a managed dll from inside an arx file.

    With thanks in advance.

    Massoud

     

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,167
    Registered: ‎04-09-2008

    Re: How to load a Managed dll from an arx file?

    05-04-2012 12:44 AM in reply to: massoudshakeri

    1) LoadLibrary()
    2) Also acdbmgd.lib export function LoadManagedDll:
    enum Acad::ErrorStatus __stdcall LoadManagedDll(ACHAR const *path);
    Sample:

    enum Acad::ErrorStatus __stdcall LoadManagedDll(ACHAR const *path);
    static int ads_netload(void)
    {
      struct resbuf *pArgs = acedGetArgs () ;
      acedRetNil();
      if (pArgs && pArgs->restype == RTSTR) {
      Acad::ErrorStatus es = LoadManagedDll(pArgs->resval.rstring);
      if (es != Acad::eOk) {
         acutPrintf(_T("\nLoadManagedDll(\"%s\")=%s"),
            pArgs->resval.rstring,acadErrorStatusText(es));
      } else 
        acedRetStr(pArgs->resval.rstring);
      } 
      return (RSRSLT) ;
    }

     


    Пожалуйста не забывайте про Утвердить в качестве решения!Утвердить в качестве решения и Give Kudos!Баллы
    Please remember to Accept Solution!Accept as Solution and Give Kudos!Kudos

    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎08-07-2009

    Re: How to load a Managed dll from an arx file?

    05-05-2012 11:21 AM in reply to: massoudshakeri

    Thanks for the response. But none of these methods work.

    I need somehow make AutoCAD to load that managed DLL, in the same way acrxDynamicLinker->loadModule works. I do not think LoadLibrary() can do this.

    The second method did not work either.

    

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,167
    Registered: ‎04-09-2008

    Re: How to load a Managed dll from an arx file?

    05-05-2012 12:40 PM in reply to: massoudshakeri

    massoudshakeri wrote:

    The second method did not work either.

    


    Try again. I've attached solution which was tested with AutoCAD 2012. It export command MyNetLoad which is analog of NETLOAD command and lisp function (netload <path_to_managed_dll>)

     


    Пожалуйста не забывайте про Утвердить в качестве решения!Утвердить в качестве решения и Give Kudos!Баллы
    Please remember to Accept Solution!Accept as Solution and Give Kudos!Kudos

    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎08-07-2009

    Re: How to load a Managed dll from an arx file?

    05-07-2012 10:31 AM in reply to: massoudshakeri

    Hi Alexander,

    Thank you very much.

    It worked for me.

     

    Best Regards

    Massoud

    

    

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,167
    Registered: ‎04-09-2008

    Re: How to load a Managed dll from an arx file?

    05-07-2012 10:36 AM in reply to: massoudshakeri

    It worked for me.

    What about Accept Solution?


    Пожалуйста не забывайте про Утвердить в качестве решения!Утвердить в качестве решения и Give Kudos!Баллы
    Please remember to Accept Solution!Accept as Solution and Give Kudos!Kudos

    Please use plain text.