|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Upgrading Visual C# Applications to Visual Studio 2005
When you open a project or solution file created by an earlier version of Visual Studio, the Upgrade Wizard steps you through the process of converting your project to Visual Studio 2005. The Upgrade Wizard performs many tasks for you: creating new properties and attributes, deleting obsolete ones, and so on, but because error checking has been tightened up, you might encounter new error or warning messages that were not produced by the previous version of the compiler. Thus, the final step in upgrading an existing application is to make the code changes needed to resolve any new errors.
Often, code that produced one message in prior versions of the C# compiler now produces a different message in the current version. Usually this is because a general message has been replaced by a more specific one. Because no change in code is required, we do not document such differences.
The following are the new messages that the Upgrade Wizard generates because of stricter error checking.
New Error and Warning Messages
CS0121: Ambiguous call
Due to an implicit conversion, the compiler was not able to call one form of an overloaded method. You can resolve this error in the following ways:
Specify the method parameters in such a way that implicit conversion does not take place.
Remove all overloads for the method.
Cast to proper type before calling the method.
CS0122: Method inaccessible due to its protection level
You may receive this error when referencing a type in an assembly compiled by C++ that was compiled with the /d1PrivateNativeTypes compiler option.
This error occurs because in the current release, a C++ assembly produces a signature that uses a type that is not marked as public.
You can work around this issue by using the /test:AllowBadRetTypeAccess compiler option. This option will be removed when this feature has been fixed.
CS0429: Unreachable expression code detected
This error occurs whenever part of an expression in your code is unreachable. For example, the condition false && myTest() meets this criteria because the myTest() method will never get evaluated because the left hand side of the && operation is always false. To fix this, redo the logic test to eliminate the unreachable code.
CS0441: A class cannot be both static and sealed
All static classes are also sealed classes. The C# language specification prohibits specifying both modifiers on a class, and the compiler now reports this as an error.
To fix this error, remove sealed from the class.
CS1699: Warning on use of assembly signing attributes
The assembly attributes that specify signing have been moved from code to compiler options. Using the AssemblyKeyFile or AssemblyKeyName attributes in code now produces this warning.
Instead of these attributes, you should use the following compiler options:
use thecompiler option instead of the AssemblyKeyFile attribute, and use instead of AssemblyKeyName.
Not switching to the command-line options may hamper compiler diagnostics when using friend assemblies.
If you are using, you can convert this back into a warning by adding /warnaserror-:1699 to your compiler command line. If necessary, you can shut off the warning by using /nowarn:1699.
Incremental compilation removed
The /incremental compiler option has been removed. The Edit and Continue feature replaces this functionality.