[Mono-dev] Avoiding references to ExtensionAttribute so a program is compatible with MS.NET 2.0

Avery Pennarun apenwarr at gmail.com
Sun Nov 16 04:43:13 EST 2008


I'm attempting to compile a C# program that uses extension methods using
mono, and have it run under both mono and MS.NET.

This works fine (gmcs when the target Windows system is running
MS.NET 3.5, but not when running MS.NET 2.0.  The problem appears to be the
one described here:



If I understand correctly, creating an extension method results in your code
referring to an attribute that is only in System.Core v3.5.0.0 or higher.
However, this attribute doesn't actually do anything.

It appears that the solution the IronPython guys claim to have used won't
work with Mono, which seems to be pickier about allowing you to link when
there are duplicated attribute names.  However, since we have the source
code to mono, maybe there's an even easier solution: just add an option to
gmcs to deliberately leave out that attribute on extension methods.  Would
that work?

Perhaps this is something Cecil would be good for?  I've never used it and
don't really understand what it does.

Any pointers would be appreciated.  Requiring Windows users to install .Net
3.5 to use my app is a pretty bad idea, since the installer takes *forever*
to run, and most people don't want to touch system-level stuff like that
just to install an app.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20081116/72092a87/attachment.html 

More information about the Mono-devel-list mailing list