When accepting unknown versions, should the original version also be
preserved to write it back when saving the assembly?
Something like:
m_root.Header.Version = OriginalAssemblyVersion;
in MetadataWriter.VisitMetadataRoot (MetadataRoot root).
Also, could you post the modopt fix you talk about, or is it the one
posted in the 2008 modopt bug thread?
Thanks
Richard Flamsholt wrote:
> If Cecil loads an assembly that has an unknown runtime-version in the
> manifest then the TargetRuntime will default to NET_1_0 in
> VisitAssemblyDefinition().
>
> Recently, and especially with all the .net 4.0 releases out there,
> this has become too strict for us (eqatec profiler) so I've finally
> decided to loosen up on the version-handling. My rationale is that
> it's better to accept a possibly unknown version 4.0.n assembly than
> to silently generate an assembly that will suffer inexplicable runtime
> exceptions by the CLR loader.
>
> I've included my patch here in case you, Jb, or anyone else wants to
> loosen up, too.
>
> (Just remove the EQATEC_FIX flag. And in case you wonder "well, do you
> have other fixes?" then the answer is just one: a fix for the pesky
> modopt problem which has never made it into Cecil proper)
>
>
> --- C:/Users/rfl.LINKAGE/Desktop/StructureReader.original.cs ti nov 10
> 15:38:59 2009
> +++ C:/Users/rfl.LINKAGE/Desktop/StructureReader.cs to mar 4 16:43:03
> 2010
> @@ -108,6 +108,24 @@
> case "v4.0.21006" :
> asm.Runtime = TargetRuntime.NET_4_0;
> break;
> +#if EQATEC_FIX
> + default:
> + string version =
> m_img.MetadataRoot.Header.Version.Substring(1);
> + try {
> + Version v = new Version(version);
> + switch (v.Major)
> + {
> + case 1: asm.Runtime = (v.Minor
> == 0 ? TargetRuntime.NET_1_0 :
> TargetRuntime.NET_1_1); break;
> + case 2:
> + case 3: asm.Runtime =
> TargetRuntime.NET_2_0; break;
> + case 4: asm.Runtime =
> TargetRuntime.NET_4_0; break;
> + default: throw new
> NotSupportedException("Unsupported target
> runtime version " + version);
> + }
> + } catch (Exception ex) {
> + throw new ReflectionException("Can not
> parse target runtime
> version " + version, ex);
> + }
> + break;
> +#endif
> }
>
> if ((m_img.PEFileHeader.Characteristics &
> ImageCharacteristics.Dll) != 0)
>
>
> --
> Richard
--
--
mono-cecil
To unsubscribe from this group, send email to
mono-cecil+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.