VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vb.net program crashing since 2015

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
554 Views, 5 Replies

Vb.net program crashing since 2015

Hello everyone,

I made a standalone .exe using vb.net and it keeps crashing since I'm using autocad 2015. My program use to export a face from inventor to a .dwg and add some lines of text. It still works on workstation where autocad 2013 is still use, but on my station, I only have 2015 and it's not working. Do you guys have any idea why? here is a bit of code:

 

Dim oACAD As New Object

oACAD = CreateObject("AutoCAD.Application")

oACAD.visible = False
lblStatus.Text = "Ouverture d'Autocad en cours..."
oACAD.Documents.Open(fileNameAndPath, False)
 

Dim oDoc As AutoCAD.AcadDocument
oDoc = oACAD.ActiveDocument <--- I get an error on this line : 0x80004002 (E_NOINTERFACE)). ... Unable to cast 

 

 

Complete error message (sorry but my OS is in french but I think you can get the point)

System.InvalidCastException was unhandled
HResult=-2147467262
Message=Impossible d'effectuer un cast d'un objet COM de type 'System.__ComObject' en type d'interface 'AutoCAD.AcadDocument'. Cette opération a échoué, car l'appel QueryInterface sur le composant COM pour l'interface avec l'IID '{849850B8-84BA-44A4-ADF5-C7FE74F111FC}' a échoué en raison de l'erreur suivante : Cette interface n’est pas prise en charge (Exception de HRESULT : 0x80004002 (E_NOINTERFACE)).
Source=RexLaser

5 REPLIES 5
Message 2 of 6
Ed.Jobe
in reply to: Anonymous

Is 2013 a 32 bit installation and 2015 a 64 bit installation?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 6
Anonymous
in reply to: Ed.Jobe

No, we've been on 64 bits since 2010 :S

Message 4 of 6
norman.yuan
in reply to: Anonymous

I have no problem running the same code with an Console EXE app (Win7 64-bit and AutoCAD 2015). The entire code of the console app is here:

 

Module Module1

    Sub Main()

        Console.WriteLine("Press any key to continue...")
        Console.ReadLine()

        Dim oACAD As New Object
        oACAD = CreateObject("AutoCAD.Application.20")
        oACAD.visible = False '' Or oACAD.Visible = True

        oACAD.Documents.Open("C:\Temp\DrawingTest1.dwg", False)

        Dim oDoc As AutoCAD.AcadDocument
        oDoc = oACAD.ActiveDocument

        Console.WriteLine("Press any key to exit...")
        Console.ReadLine()

        oACAD.Quit()

    End Sub

End Module

 As you can see the code is exactly the same as yours, except for the Console.WriteLine()/ReadLine(). I used "AutoCAD.Application.20" in CreateObject() because I have older version of AUtoCAD installed and I want to make sure AutoCAD2015 is created/started.

 

One thing to pay attention is that even you declare oACAD as Object and instantiate the AutoCAD session with CreateObject(...), you obviously still does not use late-binding, because the oDoc is declared as AutoCAD.AcadDocument. That means you must have set reference to AutoCAD COM library in the project.

 

Since AutoCAD2014 (or 2013?), AutoCAD installation stops adding COM PIA into GAC. That means, the .NET COM wrapper must be included in your application. However, if you use VS2012/3, the COM referenced DLL, when added as reference, is automatically set as embedded. This would cause issue for AutoCAD automation. For the referenced AutoCAD COM interop DLLs, you need to set "Embed Interop Types" to False, and set "Copy Local" to True.

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 6
Anonymous
in reply to: norman.yuan

I change it too and still doesn't work. I on Windows 8.1 64 bit, VB 2013 tryng to run an instance of Autocad 2014 64 bit.
The Acad.exe runs on task manager but after a little it stops and the next line of code gets an exeption

 

'doesn't work

Public AcadApp As Object

AcadApp = CreateObject("AutoCAD.Application")
AcadApp.Visible = True

 

'doesn't work

Dim AcadApp As Object

AcadApp = CreateObject("AutoCAD.Application")
AcadApp.Visible = True

 

'doesn't work

Dim AcadApp As AutoCAD.AcadApplication

AcadApp = CreateObject("AutoCAD.Application")
AcadApp.Visible = True

Message 6 of 6
Alfred.NESWADBA
in reply to: Anonymous

@Anonymous 

Please don't add your issue to every post that has something to do with CreateObject, it does not make sense for the helpers to have to answer one and the same question multiple times. Please let us continue there: >>>click<<<

 

- alfred -

 

 

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost