Wednesday, July 06, 2005

 

Migrating a project from Visual Studio 2005 Beta 1 to VS 2005 Beta 2

I recently upgraded a from Visual Studio 2005 Beta 1 to VS 2005 Beta 2 and had to jump through several hoops to do so. I thought I would share with you the steps that helped me get through what could easily turn into an exercise in futility.

Please read through all of the steps and comments below, before proceeding with your upgrade:
  1. Open the existing beta 1 solution in VS 2005 beta 2.
  2. Try compiling the entire solution. Watch how your app crashes and burns.
  3. Re-name the "code" folder to "app_code".
  4. All code behind partial classes belonging to .aspx pages need to inherit from the System.Web.UI.Page class or a class that is derived from the Page class. You may use the "Replace in Files" feature with Regular Expressions to expedite this. I used the following regular expression: {public partial class [A-Za-z_]* *$}
  5. All code behind partial classes belonging to .ascx pages need to inherit from the System.Web.UI.UserControl class or a class that is derived from the UserControl class. Since I had all of my user controls in one folder, I removed the folder while doing a search and replace in files. Then I added the UserControl directory back into the project folder, and re-ran the same search and replace regular expression.
  6. Any code behind classes belonging to Master Pages will need to inherit from the System.Web.UI.MasterPage class.
  7. You will probably notice that when you compiled, you received the error: CompileWith/ClassName attributes in the compilation model are no longer supported. Do a search/replace for "Classname=" to "Inherits=".
  8. Do a search/replace for "CompileWith" to "CodeFile".
  9. Replace method declarations that returned void but did not use an access modifier with "protected void" using the regular expression search "^( *\t)void", replacing with "\tprotected void".
  10. Client side scripting methods are now contained in the Page class' ClientScript class. So, you will need to replace RegisterStartupScript() with Page.ClientScript.RegisterStartupScript(), GetCallbackEventReference() with Page.ClientScript.GetCallbackEventReference(), etc... You will notice that the new Page.ClientScript.RegisterStartupScript method has a new signature that includes Type specification. I simply passed in typeof(Page), and that worked nicely.

Comments:

- If you are like me and you created a class that is derived from the Page class, you probably added an "Inherits" attribute to your pages that you wanted to use your specialized class. You will need to remove this "Inherits" attribute and edit the code behind as you used to with 1.x code, so that it inherits from your specialized class.

- I noticed that my Global.asax file which does not have a code behind file was throwing an error regarding the "Inherits" attribute. Apparently it is only needed if you are referencing a code behind file, so remove it.

- If you are upgrading an app form 1.x to Beta 2 you should be able to ignore the above instructions. Ironically enough, it is much easier to upgrade in this manner that from Beta 1 to Beta 2.

- Please understand that I am making no warranty or gaurantee that it will work for you. I just know that it worked well for me. I hope you find this information useful.


Comments: Post a Comment

Links to this post:

Create a Link



<< Home
Content copyright ©2003-2006 Tod Birdsall