Tuesday, October 12, 2010

Common issues when migrating from 3.5 to 4.0

I recently had to migrate one of our enterprise level applications to .net 4.0 and it was a challenge to say the least in terms of isolating fixes for some of the obscure issues. Here is a list of some of the issues that I face while migrating and how I overcame them:

Problem) There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined

Solution) In .net 4.0 the config sections scriptResourceHandler, jsonSerialization, profileService, authenticationService, roleService amongst others are defined in the machine.config. So there is no longer a need to explicitly define them. Of course if you need to change any of these settings then you will need to remove the config sections http://msdn.microsoft.com/en-us/library/ms228258.aspx and then readd the config section and modify the settings as desired.

Problem) ‘Schema specified is not valid’ error message gets thrown while trying to upgrade your Entity Model to 4.0.

Solution) Regenerate the connection string of your model. It should look like some below. As you can see, the upgraded version of EF required much more info about where to get its metadata resource.

add name="TestEntities" connectionString="metadata=res://*/BusinessRuleEntity.csdl|res://*/BusinessRuleEntity.ssdl|res://*/BusinessRuleEntity.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(local)\sqldefault;Initial Catalog=TestDB;User ID=TestUser;Password=*****"" providerName="System.Data.EntityClient"

Problem) A potentially dangerous Request.Form value was detected from the client when loading an html page.

Solution) This issue can be fixed by adding the directive to the section of the web.config, and .NET then honours the directive that's in the same root web.config.