Breaking changes in .NET 4.0

后端 未结 5 1450
南笙
南笙 2020-11-27 12:23

There is a lot of information about new features and classes in new 4.0 however there are also changes that may affect existing applications, for example

  1. Ti

相关标签:
5条回答
  • 2020-11-27 13:01

    The languages documentation team publishes separate documents for C# and VB breaking changes:

    VB: http://msdn.microsoft.com/en-us/library/cc714070%28VS.100%29.aspx

    C#: http://msdn.microsoft.com/en-us/library/ee855831%28VS.100%29.aspx

    I wrote the C# one and included covariance and contravariance breaking changes mentioned by Eric Lippert, and events changes discussed by Chris Burrows. There are also some breaking changes around optional parameters, embedded interop types, and method group type inference.

    Update:

    One more useful document (from .NET documentation team): http://msdn.microsoft.com/en-us/library/ee941656%28VS.100%29.aspx

    0 讨论(0)
  • 2020-11-27 13:03

    Also note that SmtpClient now implements IDisposable so you should now use something like this:

    using (var smtpclient = new SmtpClient())
    {
      smtpclient.Send(message);
    } 
    

    According to this page there might be more of these 'hidden jams' inside the .NET 4.0 framework. And the author suggest to find them by using FxCop on your code.

    0 讨论(0)
  • 2020-11-27 13:05

    Covariant and contravariant conversions introduce some obscure but possible breaking changes upon recompilation:

    http://blogs.msdn.com/ericlippert/archive/2007/11/02/covariance-and-contravariance-in-c-part-nine-breaking-changes.aspx

    The C# user education team compiles a list of the known potential breaking changes in the new version of the compiler, see the answer above for details.

    0 讨论(0)
  • 2020-11-27 13:05

    Just to add to the list, here's the ASP.Net official list for the RC, I haven't come across an RTM one yet.

    0 讨论(0)
  • 2020-11-27 13:07

    I've just fixed a bug in a production app which recently moved to .NET 4.0.

    Data binding that uses nested properties was throwing:

    ArgumentException: Cannot bind to the property or column 'SomeProperty' on the DataSource.

    It appears to be a known issue with a workaround. I couldn't find it on any official lists and the bug on Microsoft Connect has been closed as "Not Reproducible".

    The nested properties are all defined in strings so I had to search for them all manually.

    0 讨论(0)
提交回复
热议问题