Hello,
I have previously written an assembly (netload) application for our document management system for our office. This assembly loaded a sheet set file (dst) and read / manipulated / saved and exported data. It was very slow.
I was wondering before I progress a reimplementation if it is possible to have external application access to the dst file using the various dll files and lib files (autodesk shared / application root and object arx 2010 - 2012), and if so, which ones.
I have tried to use the same references I used for my 2010 / 2012 netload assembly but I am reciving errors like "FileNotFoundException was unhandled" I belive I have traced this to the issue that I need more or specific references in addition to:
acdbmgd.dll (.net)
acmgd.dll (.net)
acsmcomponents18 1.0 type library (com)
autodesk.autocad.interop.common (com)
the actual error message when I open a dst file is:
System.IO.FileNotFoundException was unhandled Message=Retrieving the COM class factory for component with CLSID {DA236FEC-D990-4825-95FA-651AF4C2B407} failed due to the following error: 8007007e The specified module could not be found. (Exception from HRESULT: 0x8007007E). Source=mscorlib StackTrace: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at SSMExtender.Form1.Button1_Click(Object sender, EventArgs e) in c:\users\adam kalajzich\documents\visual studio 2010\Projects\SSMExtender\SSMExtender\Form1.vb:line 33 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at SSMExtender.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
and it is occuring here:
Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.Windows Imports ACSMCOMPONENTS18Lib Imports System.Windows.Forms Imports System Public Class Form1 Private Sub ToolStripContainer1_TopToolStripPanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect End Sub Private Sub OpenToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem1.Click End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myOpenFileDialog As New OpenFileDialog If myOpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then ''Dim mySheetset As AcSmSheetSet Dim mySSMgr As New AcSmSheetSetMgr '' <<<<<<< ERRORS HERE Dim mySSDB As New AcSmDatabase End If End Sub End Class
Anyway, thanks for your time reading this, thanks for any help you can offer,if you require any more information please do not hesitate to ask.
Solved! Go to Solution.
Solved by Balaji_Ram. Go to Solution.
AutoCAD's .NET API (acdbmgd.dll/acmgd.dll) can ONLY be used inside AutoCAD process. You cannot use them in an external application (stand-alone EXE).
Since Sheet Set Manager is an COM component, you may be able to automate it from external EXE (I never dealt with it, though), along with AutoCAD via COM.
If you have to use external EXE to do the automation, is ACAD COM API not enough for AutoCAD related operation? If you have to use functionality only available in Acad .NET API from external API, you may expose the .NET API DLL as COM-able, after it is "netload"ed into AutoCAD, you could communicate with it via COM from your external app.
Lastly, if your goal is to improve the speed and if your process need to deal with AutoCAD/drawing opened in AutoCAD, doing external app would very possible make things even slower, because your app runs outside AutoCAD and has to make communication between the two processes (AutoCAD and your app), which is many/many times slower than DLLs running in AutoCAD process (such as VBA, .NET API loaded into AutoCAD).
Norman Yuan
Thankyou Norman for the responce.
for clarification, I am (hoping to) write an application that can run outside of autocad (but using the networked licenced installation) that can interigate the dst files that the engineers and draftspeople use for there projects.
You mentioned an ACAD COM API. Unfortunatly (and this may be my lack of experiance talking) but I cannot find any reference, or find any reference for this particular COM API.
Are you able to assist me or inform me where I can find theis COM API?
thanks.
To make use of the AutoCAD COM API, you will need to add references to "Autodesk.AutoCAD.Interop.dll" and "Autodesk.AutoCAD.Interop.Common.dll" from the inc-x64 / inc-win32 folder of the ObjectARX install folder.
These are the interop assemblies created using the tlb files that expose the AutoCAD COM API.
The "acadauto.chm" provides the help related to the VBA / COM API. Let me know if you need a code snippet to get started with the AutoCAD COM API.
Thanks for the references,
I am now using:
AcSmComponents18 1.0 Type Library (com)
Autodesk.AutoCAD.Interop (.net)
Autodesk.AutoCAD.Interop.Common (com)
Autodesk.AutoCAD.Interop.Common (.net)
but...
I am getting this error:
"Retrieving the COM class factory for component with CLSID {E319E833-A784-4B31-ADCC-249C23B10BB9} failed due to the following error: 8007007e The specified module could not be found. (Exception from HRESULT: 0x8007007E)."
the CLSID belongs to AcSmComponents.dll but this dll (found in the autocad installation directory) has no valid assembly or COM components.
So... is there a way to access the COM sheet set interface?
Can you check using the "Object Browser" to see what is in the "AcSmComponents.dll" ?
If you are still unable to use the "AcSmComponents.dll" then you may try generating the interop using tlbimp as shown here :
tlbimp "C:\ObjectARX2011\inc-x64\acstmgr.tlb" /out:AcStMgr.Interop.dll
After generating the interop assembly, you can add areference to "AcStMgr.Interop.dll" in your project.
If this does not help, can you provide us a small buildable sample project ?
Balaji,
Thanks for your help, but unfortunatly after building the AcStMrg.interop.dll and referencing it, I still recive the same error.
As requested please find attached a zip file of my project.
With the following changes the attached project worked ok on my system :
1. Removed all other references except "ACSMCOMPONENTS18Lib.dll", "Autodesk.AutoCAD.Interop.dll" and "Autodesk.AutoCAD.Interop.Common.dll".
2. Changed the configuration to "Any CPU"
The acmgd.dll and acdbmgd.dll should not be included as references from an external exe.
If it still does not work on your system, can you try using the following to register the interop assembly ?
gacutil /i "C:\ObjectARX2011\inc-x64\<interop.dll>"
Balaji,
Thanks for your prompt reply.
Did you open a dst file? The program compiles and runs perfectly, except when you open and then select a dst file. I am assuming that you did. so...
1)
Following your instructions I removed all autocad related references except:
(interop.)ACSMCOMPONENTS18Lib.dll (COM) located locally
Autodesk.AutoCAD.Interop.dll (.net) located in the ARX2012
Autodesk.AutoCAD.Interop.Common.dll (COM) located in the GAC, autoloaded when i select the .net version below.
Autodesk.AutoCAD.Interop.Common.dll (.net) located in the ARX2012
2)
The project is already bound to "Any CPU" found in the advanced compile options. frame work is .net 4
3)
I am using the objectARX2012
I did not have a strong name so i recreated the interop:
sn -k test.snk
tlbimp AcStMgr.tlb /out:AcStMgr.interop.dll /keyfile:test.snk <- it looks like im converting the tlb to dll, is this correct?
gacutil /i AcStMgr.interop.dll
No errors reported in the above commands.
I restarted VS 2010, I cleaned the project, i debuged the project... still same error on opening a dst file.
"Retrieving the COM class factory for component with CLSID {DA236FEC-D990-4825-95FA-651AF4C2B407} failed due to the following error: 8007007e The specified module could not be found. (Exception from HRESULT: 0x8007007E)."
Thanks again for any help you can offer.
1. Yes. I have tried opening a dst file with no errors.
2. You only need to refer to the interop assemblies from the ObjectARX folder. Are you using the "COM" tab in Visual Studio while adding references ? I directly browse to the ObjectARX folder to do this.
There does seem to be any problem in running it in my system.
Sorry, but without a reproducible sample project, there is not much that I am able to suggest.
Balaji,
Thanks again for the help. But... I have had no end of trouble trying to build a working example. I am attaching screenshots of all my references et al.
Please have a look and let me know if it is me or my computer or both. I have even attempted to build this on a laptop with no software, other than VS 2010 installed.
Hi Adam,
Looking at the error, it seems the AcSmSheetsetMgr COM component is not registered in your system. Please try registering the Sheet set manager COM component from the interop dll using the regasm utility.
I have attached the screen-shot of the references. You may directly refer to the references from the ObjectARX folder, the way I have it and also make it "Copy Local" false.
I am afraid that the error indicates that you cannot use acsmcomponents18.dll outside AutoCAD (e.g. cannnot use it in your stand-alone exe).
Norman Yuan
Hi Adam / Norman,
Thanks to Norman for pointing this out.
Yes. this COM API is only in-process and cannot be accessed through an external exe.
For some reason, I did not get the same error that you had reported.
Sorry for not being able to help you with this.
Thanks guys for the help.
Now i just got to inform the boss his "Grand Scheme" cannot be accomplished.
Maybe one day I will learn programming properly.