Created a .DLL in VS 2010.....was net loading fine in an AutoCAD 2011 installation here at work.....had to uninstall AutoCAD for some reason.....and re-install via a new company deployment install......now the same .DLL won't load....Here is the error message....
Cannot load assembly. Error details:
System.BadImageFormatException: Could not load file or assembly
'file:///D:\data\fd-ac2011\dev\AutoVSL.dll' or one of its dependencies. This
assembly is built by a runtime newer than the currently loaded runtime and
cannot be loaded.
Any ideas?
I already re-compiled the .DLL...same message
Are targerting 4.0?
It looks like you need to target 3.5 or
add or uncomment this in acad.exe.config file
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup>
Mine already says that....
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
guess I'm stuck in the water?.....No idea what to do to fix this.
Here is the sequence
1. Installed AutoCAD 2011 from a "test deployment" (They wanted me to test it out before pushing ot entire company)
2. Installed VS 2010 Pro
3. Converted one of our VBA routintes over to .net DLL
4. Tested, worked great.
5. Uninstalled AutoCAD 2011
6. Loaded VS 2010 SP1
7. Re-INstalled AutoCAD 2011..from the new company "deployment"
Now I can't load the .DLL
Excuse my ignorance on this subjetc....but here is my guess as to what happened
Computer was pointing ot Framework 3.51
When I installed VS 2010, of course it loaded Framework 4.0...and pointed computer to this????
Wrote Program (4.0 DLL)...works fine
Re-Installed AutoCAD 2011 which maybe switched system back to 3.51?
Just a wild gues....but now what do I do?
Can I convert my program bak to a .NET Framework v3.51?
Here is link that walks you through the steps for VB and C#
http://msdn.microsoft.com/en-us/library/bb398202.aspx
and in your config file it is not enclosed in <!-- -->
<!-- <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> -->
Here is another reach/guess
What if I remove my references to AcDbMgd.dll and AcMgd.dll...........then re-add them pointing to the ones in the "nw AutoCAD 2011 directory"...which show a newer version
Would that work?
The on in C:\Program Files\Autodesk\AutoCAD 2011.....shows version 18.1.49.0
ok...I see how to convert my Project back to a Framework 3.51......but now my question is?...Why do I have to do that?...what changed?
If users dont have Framework 4.0 on their machine?.....do I need to make my Project 3.51?
All this is confusing to me
Also......my acad.exe.config.....I just didn't paste the <!...thingies in my message..they were there.
thx
the
<!--
-->
tags in the XML code turn everything between them into a comment. You need to remove them to make the setting active.
That said, I am still on 2010 for a short time before we switch to 2012, but I did not need to uncomment the Supported Runtime setting to run my code, I only needed to uncomment it in order to be able to debug in VS2010. And for what it's worth, on ACAD 2010, the supported runtime version has to be set to v2 for the debugging, and in the config file the entire version number is present (v2.0.50727)
I believe that AutoCAD 2012 is the first version to be built on .NET v4.0, so you should be building your project to target 3.5
Wow....all it was.....In my acad.exe.config file....the <!--........-->.....were "commenting out the:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
Removed the <!--.......-->....and now the DLL loads....jeez
Now my next question...and it is probably a stupid one....
If the users Dont have Framework 4.0 installed on their machines.....will my "4.0 DLL" work?
Or, should I re-compile it as a 3.51 DLL?
IMHO, .NET Framework v4.0 is still to "new" to be designing against. Even though its used for AutoCAD 2012 and an increasing number of new programs, its not widely distributed enough to be certain any particulary user has it installed. Better to target the newest most established version (which I think is 3.5), unless you really need the new features found in 4.0. In that case, it would probably make sense to include either the redistributable or a link to the download.
" In that case, it would probably make sense to include either the redistributable or a link to the download."
What is the redistributable?...I had users install .NET Framework 4.0 from Microsoft website...and they still can't load my 4.0 DLL....(I can)....Thier acad.exe.config is the same as mine....
I love this .NET stuff....so easy...clear as mud....
I switched my app over to a 3.5 DLL..No Iget all kinds of error messages and it won't load on anybodies machine...including mine.
The 4.0 DLL loads on my machine...but nobody elses!!!!!!