AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Active Contributor
26 Posts
0 Kudos
Registered: ‎12-12-2011
Post 1 of 2
Accepted Solution

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

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

Hi everyone,

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

Active Contributor
26 Posts
0 Kudos
Registered: ‎12-12-2011
Post 2 of 2

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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!