Saturday, March 2, 2013

The Complete List of Migration Issues Upgrading from 3.5 to .NET 4.0


Today I upgraded our ASP.Net 3.5 project from Visual Studio 2008 to Visual Studio 2010 targeting .Net 4.0.
I ran into some issues and just wanted to list them here so others might be forewarned.
Microsoft has published a complete list of issues migrating from .NET Framework 3.5 SP1 to .NET 4.0. The list contains changes in 6 domains: Core, ASP.NET, ADO.NET, WCF, WPF, and XML.
.NET applications compiled for .NET 3.5 run without any problem if .NET Framework 4.0 is installed on the same machine because the two frameworks are installed in parallel and do not interfere with each other. But there are problems if an application is recompiled for .NET 4.0 because Microsoft’s latest runtime introduces some breaking changes but also some enhancements.
The changes appear in the following 6 domains:
The list of changes is relatively long, so we won’t cover them here. Some of them are:
Core
Application configuration file name change“If your application configuration file is named application-name.config, rename it to application-name.exe.config. For example, renameMyApp.config toMyApp.exe.config.”
Code Access Policy has been turned off.See Code Access Security Policy Compatibility and Migration.
ASP.NET
Apps running trusted code in the global cache might fail due to CAS policy change.See Code Access Security in ASP.NET 4 Applications.
ASP.NET 2.0 apps installed on IIS 6.0 may generate errors after ASP.NET 4.0 is installed.Either disable ASP.NET 4.0 or move ASP.NET 2 apps to an IIS instance that does not have ASP.NET 4 installed.
The Page Parser in ASP.NET 4.0 is stricter.Errors generated by invalid markup should be fixed.
Data
Streams“WCF Data Services no longer closes the underlying stream for read and write operations.”
Events“A System.Data.Linq.EntitySet(Of TEntity) collection now raises the ListChanged event for add and remove operations if the EntitySet(Of TEntity) is unloaded, in addition to raising the event when the collection is loaded.”
Queries“Skip(0) is no longer ignored in LINQ to SQL queries. As a result, queries that have this method might behave differently. For example, in some cases, an OrderBy clause is required with Skip(0) and the query will now throw a NotSupportedException exception if the OrderBy clause was not included.”
WCF
Configuration filesWCF support merging across config files.
Service hosting“You can no longer specify the configuration element at the service level by adding the attribute allowDefinition="MachineToApplication" to the element definition.Specifying the element at the service level is technically incorrect and causes inconsistent behavior.”
WPF
Exception handling“To enable errors to be detected earlier, WPF throws a TargetInvocationException and sets the InnerException property to critical exceptions, such as NullReferenceException,OutOfMemoryExceptionStackOverflowException, and SecurityException, instead of catching the original exception.”
Windows style“An InvalidOperationException is thrown if you try to set WindowStyle to a value other thanNone when AllowsTransparency is true andWindowState is Minimized.”
Dialog boxes“To improve reliability, the CommonDialog.ShowDialogmethod is called on the same thread that created theMicrosoft.Win32.FileDialog control.”
XML
Namespace resolvers“The XmlReader.ReadContentAs method no longer ignores theIXmlNamespaceResolver resolver passed to it.”
Whitespace“To prevent data loss when you are creating a reader, the XmlReader.Create method no longer discards significant white space.”

No comments:

Post a Comment