all groups > dotnet clr > september 2007 >
You're in the

dotnet clr

group:

enforcing .NET1.1 compatibility of autogenerated assemblies



enforcing .NET1.1 compatibility of autogenerated assemblies Edgile
9/12/2007 1:48:01 AM
dotnet clr: Hello everyone,

I have a little app the generates and saves assemblies on the fly, similarly
to xsd.exe. While xsd.exe creates you source code, my stuff creates the dll
directly using System.Reflection.Emit.AssemblyBuilder. The app is built for
..NET1.1 therefore I do not use any .NET2.0 features like generics. However,
when the assembly generation process is executed on runtime 2.0 (e.g. the
process is started from VS2005) then the resulted assemblies are not willing
to run on the old 1.1 runtime anymore. That means that the AssemblyBuilder
class on framework 2.0 adds something to the resulted assembly that is only
2.0 compatible. Is there any way that I programatically can enforce backward
compatibility?

Re: enforcing .NET1.1 compatibility of autogenerated assemblies Edgile
9/12/2007 7:04:04 AM
Hello Phill,

Thanx for the quick answer.

[quoted text, click to view]

Currently the code is in two assemblies. A library with all the code
generation logic and an executable with the GUI. If needed, I can merge them
of course. But could you ellaborate a bit more on how do I "give it a
manifest that forces it to use Fx1.1"?

[quoted text, click to view]
Re: enforcing .NET1.1 compatibility of autogenerated assemblies Phill W.
9/12/2007 1:42:32 PM
[quoted text, click to view]

I suspect the answer is "no" and the reason is /far/ more fundamental
than just language features like Generics.

The output from this process is a compiled assembly - if that's
generated by an Fx2.0 tool/compiler, then it will have a hard-wired
dependency on Fx2.0.

Generally speaking, an Fx2.0 process can load an Fx1.1 assembly; an
Fx1.1. process /can't/ load an Fx2.0 assembly.

You need to extract this processing into an executable of its own and
give it a manifest that forces it to use Fx1.1.

HTH,
Re: enforcing .NET1.1 compatibility of autogenerated assemblies Edgile
9/12/2007 2:56:02 PM
Hello guys,

[quoted text, click to view]

First of all, thanx to everyone for the contribution. This explains the
problem and also that there is no direct solution.

[quoted text, click to view]

Don't laugh! My VS2003 kept crashing and I got fed up and upgraded to VS2005
thinking that the output IL will still be the same as long as I forbore from
using 2.0 features. So you guys gave me the verdict for the ultimate
solution: format C: + reinstall. Or alternatively, I can ask my colleague to
Re: enforcing .NET1.1 compatibility of autogenerated assemblies Günter Prossliner
9/12/2007 4:42:28 PM
Hallo Edgile!

[quoted text, click to view]

Regardless if you use features of .NET 2.0 that has not been available
before... The new Compiler (and System.Reflection.Emit) generates the
Assembly's Metadata using the new Metadata-Format (which has been changed
from Version 1.x). The .NET 1.x CLR is not able to load 2.0 Assemblies.

[quoted text, click to view]

You have to generate the Assembly using .NET 1.x. There is no other way.
Because you do not use the new CLR Features I'm wondering why you are using
..NET 2.0 in this case (.NET 1.x is still fully supported). Maybe
roundtipping with ILDASM / ILASM would be a (theoritical) possible way, but
I would not recomment such things.


GP

Re: enforcing .NET1.1 compatibility of autogenerated assemblies Mattias Sjögren
9/12/2007 7:17:53 PM

[quoted text, click to view]

If you have the .NET 2.0 SDK installed you can try running
Corflags.exe /Revertclrheader and see if the resulting binary loads
correctly under 1.1.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Re: enforcing .NET1.1 compatibility of autogenerated assemblies Phill W.
9/13/2007 1:07:06 PM
[quoted text, click to view]

You're not running on Vista by any chance are you?

The '2003 IDE is /not/ [officially] supported on Vista - only '2005 SP1 is.

HTH,
AddThis Social Bookmark Button