AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Active Contributor
M_Mogharabi
Posts: 26
Registered: ‎12-12-2011
Message 1 of 2 (710 Views)
Accepted Solution

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

710 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
M_Mogharabi
Posts: 26
Registered: ‎12-12-2011
Message 2 of 2 (686 Views)

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