Month: October 2010

Converting to Framework 4.0

We all would prefer to work with the latest technology. Unfortunately we often have applications that we built just yesterday using the last version of a framework, which is now so ancient history.  Luckily when it comes to .Net Applications Microsoft has done a great job of putting together conversion wizards to bring that old app up to the latest framework.

In this article I’ll walk through the relatively painless conversion process and then highlight a couple of things I have found to be pain points in the last couple of weeks as I have migrated applications to .Net 4.0 / Visual Studio 2010 from .Net 3.5 / Visual Studio 2008.

Converting an Application

To start you’ll need to have the latest version of Visual Studio 2010.  For the purpose of this article I’ll use Visual Web Developer 2010 Express to convert an application previous built in Visual Studio 2008.

vsopen

I usually make a copy of the project ahead of time in a separate folder before beginning,  That way if something goes wrong then nothing is lost.  (Although I have never had a conversion fail in an unexpected way.)

Go to File|Open Project … and browse to your solution file (*.sln) and open it.  The disk will churn a bit and you’ll be presented with the conversion wizard.

ConversionWizard

Click next and Visual Studio will ask you if you want to back things up first.  Since I am already working on a copy I choose no here.  I just don’t really like were Visual Studio puts the back up by default, which ends up being along side your project.

BackUp

Clicking next will bring you to the confirmation screen.

Finish

Now the disk will churn for a bit again and then you will get a dialog asking if you want to upgrade to framework 4.0 as well.

Convert

If you click no here your project will be converted to the 2010 Project format, but it will be left targeting the 3.5 framework (You can switch that later if you wish in the project properties).  If you click yes, the project file will be updated and the framework will be set to 4.0.  Pretty straight forward…

results

Once you choose an option things will churn a bit again and eventually you’ll be presented with a Conversion Report.

I did get a failure here, but it was expected.  The particular solution I converted had a number of projects in it including a couple of libraries, a web application, and a WinForms application.   Since I am opening this with Visual Web Developer the WinForms application did not load.  No problem, that was expected.

A Couple of Things to Note

After doing a few conversions I have run into a couple things you should know.

  1. In Framework 3.5 the Menu control renders by default as tables.  In 4.0 it renders by default as an unordered list.  The control has a property (RenderMode) that can be set to Default, Tables, or List.  So it’s your choice, you can set the value to Tables and move happily along, or convert things to work correctly as a List. If you choose to set it to List, I would, recommend setting the property to List explicitly.  I’ve seen things behave differently in different environments (IIS Versions) when set to default.
  2. There is a “Known Issue” in 4.0 where if you call __doPostback(‘foo’, ‘bar’) inside an AJAX Update Panel and the referenced control is not outside the Update Panel then nothing seems to happen at all.  The work around is to put a control with the specified name outside the Panel, however I have not tried this yet, In this particular case I opted to back off the 4.0 conversion for now because that change would have to be made in a number of complicated places in a critical application and it will require a large amount of testing to confirm the fix.  I converted this application to Visual Studio 2010, but left it at Framework 3.5.
  3. In the case when you have an ASP.Net web form that is allowing for example, HTML input, you may see an error something like: “A potentially dangerous Request.Form value was detected from the client…”.  We used to set RequestValidation=”false” on each page to get around this, but this does not in and of itself work in 4.0.  In 4.0 you will need to add an attribute(requestValidationMode=”2.0″) to the httpRuntime element in your web.config file to allow you to override the RequestValidation on the page level.  It looks something like this.

<httpRuntime requestValidationMode=”2.0″ />

You do still have to also set RequestValidation=”false” on the page as well.

More Information

There is a decent whitepaper on breaking changes in 4.0 on the ASP.Net web site at http://www.asp.net/learn/whitepapers/aspnet4/breaking-changes

Windows Azure PDC10 Announcements

On the first day of PDC 2010 on Thursday Microsoft announced a slew of new features coming in Windows Azure including:

  • Remote Desktop (woot!)
  • A new Virtual Machine Role
  • Elevated Privileges
  • Full IIS
  • New Network functionality called Windows Azure Virtual Network.
  • New “Affordable” platform access options.
  • A new Silverlight based Portal for Managing deployments etc.

There were also announcements of new features coming in 2011.

Get all the details from the Windows Azure Team Blog or check out the PDC 2010 site.

Essential Tools List

Every developer’s blog has to have a tools list, so here’s mine.

Microsoft Visual Studio

Visual Studio is the obvious choice for an IDE.  The Express Editions are free and available from http://www.microsoft.com/express/Downloads/.  You can also get a free Express Edition of SQL Server from here as well.

There is also a free trial (The trial period lasts for 30 days with the option to register the software for an additional 60 days.) of the Professional Edition available from  http://www.microsoft.com/downloads/en/details.aspx?FamilyID=26bae65f-b0df-4081-ae6e-1d828993d4d0&displaylang=en.

Paint.net

Paint.net is a fast, lightweight image editor written in .net.  Best of all it’s free!  This is a great little program that I use almost everyday for all sorts of tasks like resizing, cropping, chopping and editing images for both web sites and Windows applications.  Check it out and download it from http://www.getpaint.net/.

LinqPad

LinqPad is a really great tool with lots of uses.  I use it as a scratch pad to test little snippets of code (They don’t have to be Linq related either!) and to work out complex Linq Queries.  I have also used it to write scripts to move/transform data, or do some one time maintenance task.

The latest version is fully compatible with C# 4.0 and .Net Framework 4.0.  The basic version is free and you can add on the auto-complete (Intellisense?) feature for just $39.00.  Learn more and/or download it at http://www.linqpad.net/.

Fiddler

Ever have a web page or service that was doing something completely unexpected?  Often it is helpful to be able to watch what is happening under the covers at the http request/response level.  That’s just what Fiddler does for you.  You can even modify (fiddle with?) the request before it actually goes out and much more.  This is a must have!  Get it at http://www.fiddler2.com/fiddler2/.

Jing

Jing is a screen capture utility from TechSmith.  The free version allows you to grab screenshots by dragging a rectangle around the area you want to capture.  Very handy for grabbing shot of dialogs or error messages.  It will also capture video and save it as a .swf so you can post short videos to the web.  There is a pro version (pay) that enhances the application and removes the made with Jing from the end of your videos.  Check it out on the TechSmith site @ http://www.techsmith.com/jing/.

 

More coming soon…