I am trying to develop a desktop application and by using AutoCAD dll trying to read DWG image attributes, by using .NET C# windows application,
I am getting the below error
System.BadImageFormatException HResult=0x8007000B
Message=Could not load file or assembly 'Acdbmgd, Version=24.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source=CADWindowsApp
StackTrace:
at CADWindowsApp.AttributeReaderCommands.ReadAttributes() in D:\Demo\Automation_tool\CADWindowsApp\CADWindowsApp\Class1.cs:line 64
at CADWindowsApp.frmImage.button1_Click(Object sender, EventArgs e) in D:\Demo\Automation_tool\CADWindowsApp\CADWindowsApp\frmImage.cs:line 20
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(Form mainForm)
at CADWindowsApp.Program.Main() in D:\Demo\Automation_tool\CADWindowsApp\CADWindowsApp\Program.cs:line 30
It looks like you are trying to use the AutoCAD managed API from a standalone Windows executable. That's not possible, you can only use the AutoCAD managed API from a managed extension .DLL that is loaded into AutoCAD using the NETLOAD command.
From a standalone windows executable you can use the COM API, or you can build a hybrid application that involves both a standalone Windows executable and a managed extension component that can communicate with each other using COM.
You can find examples of using both approaches by searching this discussion group and this blog
Can't find what you're looking for? Ask the community or share your knowledge.