Visual studio feeds

All Visual Studio blogs in one place


Enter your email address:

Delivered by FeedBurner

Increase your website traffic with



Anti-spam: How many eyes has a typical person?

Follow us on FB


Anatomy of a .NET Assembly - Type forwards

AddThis Social Bookmark Button
If you've ever had a poke around System.dll or System.Core.dll in Reflector, you may have noticed TypeForwardedToAttributes applied to the assembly: [assembly: TypeForwardedTo(typeof(Lazy<>))] [assembly: TypeForwardedTo(typeof(LazyThreadSafetyMode))] [assembly: TypeForwardedTo(typeof(Action))] [assembly: TypeForwardedTo(typeof(Action<,>))] [assembly: TypeForwardedTo(typeof(Action<,,>))] [assembly: TypeForwardedTo(typeof(Action<,,,>))] This post has a look at what these are, and how they're implemented. Type forwards TypeForwardedToAttribute is part of a feature introduced in .NET 2 - Type forwarding. As the documentation says, this is a feature that allows a type to be moved to a different assembly without having to recompile assemblies using that type. This is used extensively by the class libraries when types were moved from System.Core.dll to mscorlib.dll between .NET 3.5 and
4, allowing assemblies compiled against .NET 2 and 3.5 to run on the .NET 4 framework as-is, without having to be recompiled. However, if you think about it, this is much more than a simple attribute; this is a core change to the CLR type resolution mechanism. Every type that is resolved in an assembly first has to check for the existance of a type forward indicating the type has been moved somewhere else. This isn't something that can easily be represented in a simple attribute; TypeForwardedToAttribute is actually an example of a pseudo custom attribute. ExportedType First, a bit of background. The...(Read whole news on source site)

Home : Blog List : Simon Cooper : Anatomy of a .NET Assembly - Type forwards