In the original Star Wars movie there is a classic scene where Obi-Wan and Luke enter the Tatooine Space-port.

Storm trooper: Let me see your identification.
Obi-Wan: [with a small wave of his hand] You don't need to see his identification.
Storm trooper: We don't need to see his identification.
Obi-Wan: These aren't the droids you're looking for.
Storm trooper: These aren't the droids we're looking for.
Obi-Wan: He can go about his business.
Storm trooper: You can go about your business.
Obi-Wan: Move along.
Storm trooper: Move along... move along.

Obi-Wan uses the “Jedi Mind Trick” on the Storm trooper to “suggest” what he should do.

Sometimes we need to do the same thing in .NET.

Consider the scenario where you have developed a class – MyClass - in a Library that you distribute - MyLibrary.  You want to reorganize your libraries and create a new – MyNewLibrary - and move MyClass to the new asembly.  The problem is that all your existing applications expect MyClass to be in MyLibrary not MyNewLibrary.

In .NET 2.0 a new assembly level attribute was added – TypeForwardedTo(typeof(MyClass)). This can be applied to the “old” version of the Library, and your applications will not break.

The procedure is as follows:

  1. Move the MyClass code from MyLibrary to MyNewLibrary .
  2. Put TypeForwardedTo(typeof(MyClass)). in MyLibrary for the MyClass type.
  3. Compile the newly created MyNewLibrary .
  4. Add a reference of MyNewLibrary into MyLibrary .
  5. Recompile MyLibrary (because MyClass used to be located in that).

When your application attempts to get a reference to MyClass from MyLibrary  – it will be redirected to the correct MyNewLibrary.

Or as Obi-Wan would say - “This is not the assembly you’re looking for.”

There is one corollary to this.  In .NET 2.0 MyLibrary cannot be a VB.NET assembly – this has been fixed in .NET 3.5 (VB9).

I am currently investigating whether this could be an approach to the “Breaking Changes” issue, as we move forward with DotNetNuke development.


Posted in: ASP.NET , DotNetNuke  Tags:

Comments


November 26. 2008 12:52
erik van ballegoij
Unless we are going to convert DNN to C# (Not!), I can see a requirement for .Net 3.5 coming up Smile

Comments are closed

 Search Blog

 Adsense

 Calendar

«  March 2010  »
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234
View posts in large calendar
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010 Thoughts from the Wet Coast