Can anyone provide a real life senario where Type Forward is use?
The BCL libraries commonly use the TypeForwardedTo
attribute when different versions of the framework move a type between assemblies. For example, the Func<>
style delegates were moved from System.Core in the 3.5 framework to mscorlib in the 4.0 framework.
You can view real world uses of this by opening System.Core.dll from 4.0 in ildasm, double clicking on the Manifest node and looking for all of the lines similar to the following
.class extern forwarder System.Func`1
{
.assembly extern mscorlib
}
.class extern forwarder System.Func`2
{
.assembly extern mscorlib
}
.class extern forwarder System.Func`3
{
.assembly extern mscorlib
}
From msdn:
For example, suppose an application uses the Example class in an assembly named Utility.dll. The developers of Utility.dll might decide to refactor the assembly, and in the process they might move the Example class to another assembly. If the old version of Utility.dll is replaced by the new version of Utility.dll and its companion assembly, the application that uses the Example class fails because it cannot locate the Example class in the new version of Utility.dll.
The developers of Utility.dll can avoid this by forwarding requests for the Example class, using the TypeForwardedToAttribute attribute. If the attribute has been applied to the new version of Utility.dll, requests for the Example class are forwarded to the assembly that now contains the class. The existing application continues to function normally, without recompilation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With