Message 1 of 3
Creating a New Instance of AutoCAD .NET and working with Documents
Not applicable
01-23-2013
08:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey all!
I've run into to some trouble when trying to create an instance of AutoCAD.
In fact, the behavior is strange, and it leads to believe it's not from creating an instance! 😛
Anyways, I'm coming straight from VB6, so I used:
Dim rpDoc As AcadApplication
Set rpDoc =CreateObject("AutoCAD.Application")
And this worked fine...
Now with moving to VB.NET I'm having some real issues.
Here I'm creating the instance inside a module:
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop
Public acadApp As AcadApplication = New AcadApplication
Inside the main Form, in a button1_Click event, I have this:
acadApp.Documents.Item("Drawing1.dwg").Close(False)
acadApp.Visible = True
acadApp.Visible = True
acadDoc = acadApp.Documents.Open(Me.FileName) 'OpenAcadFile(Me.FileName)
The program crashes the first time it tries to use "acadApp", and I this error:
And sometimes I will see a "acad.exe" in processes in Task Manager
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Project1.exe
Addition information: Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
Also, I'd like to know what references I need. After doing lots of internet browsing, I came
up with a whole bunch of different entries I am currenlty using:
AcMgd
AcDbMgd
AutoCAD 2012 Type Library
AutoCAD/ObjectDBX Common 16.0 Type Library
Autodesk.AutoCAD.Interop.Common
So.. If you have any advice or know why I am receiving the error, it'd be greatly appreciated!
PS: The errors are also attached to this post.
Thanks much, and God Bless!
-Nick.