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

Help with 6A221957-2D85-42A7-8E19-BE33950D1DEB - Class not registered

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Greg.Moore
1208 Views, 8 Replies

Help with 6A221957-2D85-42A7-8E19-BE33950D1DEB - Class not registered

Forgive me, I'm a rather complete newbie to this, so I may be barking up the wrong tree, or asking in the wrong place, but here goes.

 

I've been tasked with updating an in-house app, originally written in VB6, now being maintained in VB.NET (Visual Studio 2010).

 

First thing I need to do is to be able to simply open a Autocad file when the user clicks on a button. (Note, this functionality works in the older code, with Autocad 2009).

 

So far I have:

Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.Interop

 

Public AcadDoc As AutoCAD.Interop.AcadDocument = New AutoCAD.Interop.AcadDocument
Public ACADapp As AutoCAD.Interop.AcadApplication = New AutoCAD.Interop.AcadApplication
Public ACADmod As AutoCAD.Interop.Common.AcadModelSpace = New AutoCAD.Interop.Common.AcadModelSpace

 

This breaks however before I even get to the code to do anything.  The first declaration fails with:

Retrieving the COM class factory for component with CLSID {6A221957-2D85-42A7-8E19-BE33950D1DEB} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

 

My first guess would be needing to register the DLLs, but when I try, I get an error:

The module Autodesk.AutoCad.Interop.Commonl.dll was loaded, but the entry-poin DLLRegisterServer was not found, etc.

 

I have Autodesk Inventor 2013 on machine, but the users will have Autocad 2013 itself installed.

I have alos downloaded and installed ObjectARX 2013 (and in fact that's where the DLLs are being loaded from in theory.)

 

I'm assuming I'm making a rookie mistake here.

(I'm also unclear if this is the proper way moving forward or if the newer dlls with 2013 should be used instead.)

 

Thanks for any help you can give.

 

One more thing to add if it makes a differences:

Because of a reliance on another 3rd party DLL, I have to build this app as an x86 app. I can't use "Any" or x64.

8 REPLIES 8
Message 2 of 9
hgasty1001
in reply to: Greg.Moore

Hi,

 

You have a problem, interop it's platform dependent (32 xor 64), so you have few alternatives:

 

1.-Add references to the dlls included in the Inc-win32 folder of the SDK

2.-Use late binding or dynamic loading the dll

3.-Do not use interop at all (prefered solution), there are very few (if any) things that you can not do with the managed API

 

You can find some examples of late binding here:Late Binding

 

Gaston Nunez

 

Message 3 of 9
Greg.Moore
in reply to: hgasty1001


@hgasty1001 wrote:

Hi,

 

You have a problem, interop it's platform dependent (32 xor 64), so you have few alternatives:

 

1.-Add references to the dlls included in the Inc-win32 folder of the SDK

2.-Use late binding or dynamic loading the dll

3.-Do not use interop at all (prefered solution), there are very few (if any) things that you can not do with the managed API

 

You can find some examples of late binding here:Late Binding

 

Gaston Nunez

 


Thanks.  In reference to option #1: I am including the references to exactly those DLLs.

e.g.: 

Autodesk.AutoCAD.Interop points to: C:\ObjectARX 2013\inc-win32\Autodesk.AutoCAD.Interop.dll

Autodesk.AutoCAD.Interop.Common points to C:\ObjectARX 2013\inc-win32\Autodesk.AutoCAD.Interop.Common.dll

 

As for option #2, I'd prefer to avoid that.

 

Actually option #3 is my preferred solution also (even if it means a lot more work) since I want this app to be forward compatible.

 

I tried the code example here:

http://docs.autodesk.com/ACD/2013/ENU/index.html?url=files/GUID-330A8DCB-626F-4271-8B89-9773A7631D87...

But get the error others have received:

 

Which this post seems to give a solution to:

http://forums.autodesk.com/t5/NET/Open-is-not-a-member-of-ApplicationServices-DocumentCollection/td-...

 

So, I've decided to reduce this to a simple problem and see if I can open a DWG in the simplest project available:

 

I have:

Imports System.IO
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime

 

Dim strfilename As String = "C:\test.dwg"
MsgBox("this will open file: " & strfilename)


Dim acDoc As DocumentCollection

If (File.Exists(strfilename)) Then
   DocumentCollectionExtension.Open(acDoc, strfilename, False)
Else
   'acDocMgr.MdiActiveDocument.Editor.WriteMessage("File " & strfilename & " does not exist.")
End If

 

And get 

 

Common Language Runtime detected an invalid program.

 

I'm guessing it's because it's somehow not properly finding autocad (or in my case, autocad inventor)?

 

Again, thanks for the help.

Message 4 of 9
hgasty1001
in reply to: Greg.Moore

Hi,

 

What you mean by "m guessing it's because it's somehow not properly finding autocad..."?, if you are trying to use that code in AutoCAD, you should first netload the dll, if you are trying that code from an external exe, it wont work as managed code *need* to be netloaded in AutoCAD.

 

Gaston Nunez 

Message 5 of 9
Greg.Moore
in reply to: hgasty1001

Yeah, this is an external application.

So I'm not sure what you mean by "it wont work as managed code *need* to be netloaded in AutoCAD"

 

Basically the end solution is I need an external app that will open an autocad drawing (with autocad 2013).

An older version of this external app does work with autocad 2009. I need to update it to work with 2013.

 

Like I say, I may be barking up the wrong tree (heck I may be in the wrong forest 🙂

Message 6 of 9
hgasty1001
in reply to: Greg.Moore

Hi,

 

May I'm wrong but I think that any code that use the standar dll (AcMgd,AcdbMgd, and AcCoreMgd) need to be loaded in the AutoCAD process space, an external application it's an out of process (in reference to AutoCAD), so I think there is no way (perhaps using some obscure hack) to do that. So you have to reformulate the architecture of the application.

 

Gaston Nunez

 

 

Message 7 of 9
Greg.Moore
in reply to: hgasty1001

Thanks. No, I think you're right. I think I'm back to going with option #1.

 

 

Message 8 of 9
norman.yuan
in reply to: Greg.Moore

You did not mention, but I guess the application you are doing (ro converting from VB6) is an stand-alone EXE app. IMO, automating AutoCAD from external EXE app is not a best type of application in most cases. But you may have good reason to do so. No more comment on this without knowing more details.

 

However, the error you ran into is not due to any reason you have discussed in the the thread. The reason of error is:

 

You CANNOT "New" a AcadDocument, NOR you can "NEW" AcadModelSpace.

 

You can only create a new AcadDocument instance by AcadDocuments.Open()/Add().

 

That is, you first obtain an AcadApplication instance, which is "New"-able class. That you do something like

 

AcadDocument doc=acadApp.Documents.Open("...") or

AcadDocument doc=AcadApp.Documents.Add("...")

 

Once you have an instance of an AcadDocument, you can reach the MOdelSpace of the drawing by

 

doc.ModelSpace

 

 

Message 9 of 9
Greg.Moore
in reply to: norman.yuan

Bingo!

 

That solves that particular problem.

(Running into new ones, but I'll open a separate thread for that.)

 

I'm so used to assigning something (usually a "new" ) when defining stuff I added that into the code and never thought about it.

 

 I'm a step closer to where I need to be. 

 

Thanks.

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