.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot Create ActiveX Component error when AutoCAD 2010 is slow to load

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
1565 Views, 2 Replies

Cannot Create ActiveX Component error when AutoCAD 2010 is slow to load

There seems to be a fixed timeout period that results in an error of

Cannot Create ActiveX Component

when I am opening AutoCAD 2010 in my VB.NET program.

 

When AutoCAD loads in a shorter time I don't get the error, but most of the time AutoCAD completes loading about 1 second after I get the error and my application variable does not get initialized.

 

Does anyone know how to increase the timeout or have my program wait longer so I get a reliable way of opening AutoCAD 2010?

 

I used this same approach with no problems with AutoCAD 2008 on XP. My program also invokes Excel 2010 with no problems at all. This problem seems to be associated only with AutoCAD 2010.

 

Here's how I am invoking AutoCAD 2010 from VB.NET 2010 on Windows 7. Try

   If oAcad IsNothingThen'oAcad = New AutoCAD.AcadApplication

             lblStatus.Text ="Opening AutoCAD..."

             oAcad = CreateObject("AutoCAD.Application") 'Version independent'

             lblStatus.Text ="AutoCAD Loaded"

             oAcad.Visible =True

   EndIf

Catch ex AsException'

   Try

     'If I put break here and wait a second or 2 until AutoCAD has a chance to complete loading, then the GetObject call works, otherwise it errors the same way

            oAcad = GetObject(,"AutoCAD.Application")

   Catch ex2 AsException

           MsgBox(ex2.Message,MsgBoxStyle.OkOnly, "Error opening AutoCAD application")

     Exit Sub

   EndTry

EndTry

 

Note that If I put a break in the first catch above and wait a few seconds before proceeding, the getObject call will execute successfully, but otherwise with no breakl if it happens immediately on the Createobject error it will produce the same error immediately. Obviousy I can create a delay in the first catch where I an putting the break, but this seems to be a rather poor workaround.

 

Any ideas?

2 REPLIES 2
Message 2 of 3
Alfred.NESWADBA
in reply to: Anonymous

Hi,

 

>> Does anyone know how to increase the timeout or have my program wait longer so I get a reliable way of opening AutoCAD 2010?

You can go through "Processes", first find the process for your AutoCAD, then wait with "Thread.Sleep" until the process shows you that AutoCAD is quiescent.

To set it up to 2 seconds is not save at all.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 3
Anonymous
in reply to: Alfred.NESWADBA

I am probably missing something here. I looked up Processes and as far as I can see this is available in the EnvDTE namespace which is meant for Automation and extensibility of the VS IDE. How does that help me when with a compiled executable at run time?

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost