Untitled

Random thoughts about everything and nothing

System.Runtime.CompilerServices.TypeForwardedToAttribute

leave a comment »

I’ve been playing with the TypeForwardedTo attribute (new in .NET 2.0). The basic idea is this:

You have an application that references your assemby a1 which includes the class Util. Some time later you realize that you want to put this class in your framework assembly b1. You have one problem however, you can’t recompile the initial application (breaking changes perhaps?). Oops!

The TypeForwaredTo attribute is your rescue in this scenario. Just go ahead with your planned move and place this attribute in the original assembly: [assembly: TypeForwardedTo(typeof(Util))]
Now I recompile both assemblies and place them in the application’s (bin) directory.

To warm up, try this example at Junfeng Zhang’s blog.

Note: Be sure to read the restrictions part in the example! Don’t forget when using namespaces (which you probably do :-°)…keep them the same…

Advertisements

Written by Michael

April 14, 2006 at 2:03 pm

Posted in .NET

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: