Archive for April 2006
System.Runtime.CompilerServices.TypeForwardedToAttribute
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…
Expand your Opportunities with TFS
Take a look at the new Expand your Opportunities site at MSDN. IMO a better organized learning space….hope to see more of these in the further…
?? operator in C#
The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand.
Kewl….