.NET

Reply
Member
AashishM
Posts: 4
Registered: ‎11-23-2009
Message 1 of 7 (1,987 Views)

Get the error: Could not load file or assembly 'acdbmgd

1987 Views, 6 Replies
12-01-2009 06:56 AM
We are building a product using the AutoCAD .NET API and Visual Studio 2008 SP1.
Our product needs to support AutoCAD 2007 through 2010.

Environment:
The OS is XP Professional SP3 and has the following (relevant) programs:
1. AutoCAD 2007, 2008 and 2010, Autodesk DWF Viewer 7, Autodesk Design Review 2010
2. .NET Framework 1.1 thru 3.5 SP1

If it matters, this is all running in a VM.

Visual Studio project details:
I have a project reference to the following AutoCAD DLLs:
1. C:\Program Files\AutoCAD 2007\acdbmgd.dll (Version 17.0.209.0)
2. C:\Program Files\AutoCAD 2007\acmgd.dll (Version 17.0.209.0)
3. The "AutoCAD 2008 Type Library" COM component
4. The "OLE Automation" COM component

Problem:
When I run the project (with or without debug mode), I get the following System.Reflection.ReflectionTypeLoadException:
{"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."}

Here's the value of LoaderException property:
{"Could not load file or assembly 'acdbmgd, Version=17.0.209.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))":"acdbmgd, Version=17.0.209.0, Culture=neutral, PublicKeyToken=null"}

If it helps, here are other details:
Source: mscorlib
StackTrace:
at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at Microsoft.VisualStudio.Tools.UserControlTestContainer.LoadAssemblyFromFile(String fileName)
at Microsoft.VisualStudio.Tools.UserControlTestContainer.UserControlTestContainer_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
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(Form mainForm)
at Microsoft.VisualStudio.Tools.UserControlTestContainer.Main(String[] args)

I am not sure why I am getting this error. Any help would be greatly appreciated. Thanks.

- Aashish
*Expert Elite*
norman.yuan
Posts: 965
Registered: ‎04-27-2009
Message 2 of 7 (1,987 Views)

Re: Get the error: Could not load file or assembly 'acdbmgd

12-01-2009 10:57 AM in reply to: AashishM
What kind of product you are doing? A stand-alone exe app (since I saw "... System.Windows.Forms.Application.Run(Form mainForm).." in the error message), or a .NET DLL loading into Acad via "NETLOAD" command?

If it is the former, you cannot use acdbmgd.dll/acmgd.dll in an stand-alone exe app.

If it is the latter, have you set the reference's "Copy to local" to "False"?

Also, if you develop your product against Acad2007/8/9's .NET library (acdbmgd.dll/acmgd.dll), the chances are it may not work, or may not ALWAYS work in Acad2010 or later, depending on what your product does: each Acad major release almost alway something btreaks previous APIs here or there.
Member
AashishM
Posts: 4
Registered: ‎11-23-2009
Message 3 of 7 (1,987 Views)

Re: Get the error: Could not load file or assembly 'acdbmgd

12-01-2009 11:35 AM in reply to: AashishM
The latter applies in my case, and the "Copy Local" is set to False for all the references. At this time, we don't seem to have API compatibility issues across various versions of AutoCAD, but the thing is I don't even get to the point where ACAD.exe launches (using netload to load the .NET assembly and invoking AutoCAD API methods would happen subsequently).
Member
AashishM
Posts: 4
Registered: ‎11-23-2009
Message 4 of 7 (1,987 Views)

Re: Get the error: Could not load file or assembly 'acdbmgd

12-01-2009 11:39 AM in reply to: AashishM
Ok, it appears that for some reason, my Visual Studio Project settings got reset. I changed the "Start Action" to launch ACAD.exe, and it now runs fine! I would never have guessed that. Thanks.
Member
webdeveloper.michael
Posts: 4
Registered: ‎01-30-2012
Message 5 of 7 (1,139 Views)

Re: Get the error: Could not load file or assembly 'acdbmgd

02-01-2012 11:44 AM in reply to: norman.yuan

if we can not use acdbmgd.dll/acmgd.dll in stand alone exe app. then how can we open drawing ?

i  want to open "*.dwg" file in my exe app. and modify some of the entities from that .dwg file

*Expert Elite*
Alfred.NESWADBA
Posts: 8,892
Registered: ‎06-29-2007
Message 6 of 7 (1,137 Views)

Re: Get the error: Could not load file or assembly 'acdbmgd

02-01-2012 11:47 AM in reply to: webdeveloper.michael

Hi,

 

use the COM-API instead (reference the Interop.... assemblies) to get access to the AutoCAD ActiveX-Server.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
ADN Support Specialist
augusto.goncalves
Posts: 312
Registered: ‎04-30-2009
Message 7 of 7 (1,115 Views)

Re: Get the error: Could not load file or assembly 'acdbmgd

02-02-2012 05:22 AM in reply to: webdeveloper.michael

Hi,

 

From external applications (.exe) you can ONLY use AutoCAD COM API, which mean no use of AcMgd or AcDbMgd. Using COM API you can call methods like Open and some changes can be made.

 

The way around is expose AcMgd and AcDbMgd features through COM to your external application following this blog post: http://through-the-interface.typepad.com/through_the_interface/2009/05/interfacing-an-external-com-a...

 

Regards,



Augusto Goncalves
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community