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

    AutoCAD 2010/2011/2012 DWG Format

    Reply
    Active Contributor
    M_Mogharabi
    Posts: 26
    Registered: ‎12-12-2011
    Accepted Solution

    Error : Exception has been thrown by the target of an invocation

    441 Views, 1 Replies
    01-09-2012 12:51 AM

    Hi,

    I have written an external application to drive autocad with a dll that was registered for COM. I have followed this codes to write my application however i have replaced the following code with AddNumbers() method:

     

    public string OpenDWGFile(string MyDWGFilePath)
    {
    DocumentCollection dm = Application.DocumentManager; Document doc = null; if(File.Exists(MyDWGFilePath)) { doc = dm.Open(MyDWGFilePath, false); Application.DocumentManager.MdiActiveDocument = doc;
    return "This file is exists";
     }
    else
    return "This file is not exist";
    }

     but when i run my application the autocad software open and then close immediatly and this error message is shown : Exception has been thrown by the target of an invocation.

     

    but if i comment the following lines of my code the application works without any errors:

     

    doc = dm.Open(MyDWGFilePath, false);
    Application.DocumentManager.MdiActiveDocument = doc;

     

    please help me.

    Please use plain text.
    Active Contributor
    M_Mogharabi
    Posts: 26
    Registered: ‎12-12-2011

    Re: Error : Exception has been thrown by the target of an invocation

    01-11-2012 01:51 AM in reply to: M_Mogharabi

    Hi everyone,

    I have solved my problem by using this updated code instead of previouse code.

    Please use plain text.