TheSwamp

Code Red => .NET => Topic started by: HD on October 12, 2006, 09:14:37 AM

Title: Problems Loading AutoCAD 2006 Assemblies
Post by: HD on October 12, 2006, 09:14:37 AM
Hello,

For starters, here's my operating environment. I have Windows 2000 (SP4), AutoCAD 2006, AutoCAD 2007, and Visual Studio 2005 loaded on my PC. Since I have AutoCAD 2007 installed and I am building applications for AutoCAD 2006, I uncommented <supportedRuntime version="v1.1.4322"/> in acad.exe.config

After building an AutoCAD 2006 assembly, I receive the following messages when I try to load it using the AutoCAD netload command.

Command: netload
Cannot load assembly. Error details: System.BadImageFormatException: The format
of the file 'Autodesk_StatusBar.dll' is invalid.
File name: "Autodesk_StatusBar.dll"
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase,
Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound,
Assembly locationHint, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean
stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence
securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
   at Autodesk.AutoCAD.Runtime.ExtensionLoader.Load(String fileName)
   at loadmgd()

=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\Documents and Settings\uscis002\My
Documents\Visual Studio
2005\Projects\Training\Autodesk_StatusBar\bin\Debug\Autodesk_StatusBar.dll
LOG: Appbase = C:\Program Files\AUTOCA~1\
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===

LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Documents and
Settings/uscis002/My Documents/Visual Studio
2005/Projects/Training/Autodesk_StatusBar/bin/Debug/Autodesk_StatusBar.dll.

For what it's worth, I can build AutoCAD 2007 assemblies and netload them just fine.

Any ideas?

Thanks,

Nick
Title: Re: Problems Loading AutoCAD 2006 Assemblies
Post by: T.Willey on October 12, 2006, 11:31:10 AM
Hey Nick,

   Going to take a stab in the dark, but you may have to have your project reference the 06 dll files of Acad.  Not sure if that is the problem, but it might be.  If you want I can try and compile it here and send you the dll?
Title: Re: Problems Loading AutoCAD 2006 Assemblies
Post by: T.Willey on October 12, 2006, 11:58:52 AM
Nick,

  I was able to compile the one you sent me, but I had to comment this line
Code: [Select]
//using System.Collections.Generic;
I even was able to load it into Acad, and use it.
Title: Re: Problems Loading AutoCAD 2006 Assemblies
Post by: T.Willey on October 12, 2006, 12:57:50 PM
Nick,

Guess you will have to wait for one of the masters to show up then.  I can't help anymore, sorry.
Title: Re: Problems Loading AutoCAD 2006 Assemblies
Post by: Chuck Gabriel on October 12, 2006, 01:59:22 PM
Just a guess, but have you set "Copy Local" to false in the reference properties of AcMgd.dll and AcDbMgd.dll?

If you compiled against the AutoCAD 2007 versions of these files with "Copy Local" set to true and then loaded your assembly into 2006, I can see how that might cause a problem.
Title: Re: Problems Loading AutoCAD 2006 Assemblies
Post by: It's Alive! on October 12, 2006, 06:19:45 PM
I think your issue might be that to use the older framework you need to compile your assembly with the older SDK, I.E VS2003. I am pretty sure that VS2005 can only compile the latest framework 2.0.  AutoCAD 2005 & 2006 can use the later framework 2.0 I have never needed to change this.

Dan
Title: Re: Problems Loading AutoCAD 2006 Assemblies
Post by: Glenn R on October 12, 2006, 07:31:33 PM
If you have .Net 2.0 on the CAD 2006 machines, just leave it at that and DO NOT uncomment the acad.exe.config.
I'm running 2006 and VS 2005 with no problems.

Cheers,
Glenn.
Title: Re: Problems Loading AutoCAD 2006 Assemblies
Post by: Kerry on October 18, 2006, 06:21:59 PM
Quote
AutoCAD 2006 tells me "unknown command"

Did you change the 'Copy Local' property to false for  AcMgd.dll and AcDbMgd.dll ??