Runtime Changes for Migration from .NET Framework 4.0 to 4.5.1

[ad_1]


Introduction

Runtime changes affect all apps that are running under a .NET Framework it was not compiled against and that use a particular feature.

In the topics that describe runtime changes, we have classified individual items by their expected impact, as follows:

Major
This is a significant change that affects a large number of apps or that requires substantial modification of code.

Minor
This is a change that affects a small number of apps or that requires minor modification of code.

Edge case
This is a change that affects apps under very specific scenarios that are not common.

Transparent
This is a change that has no noticeable effect on the app’s developer or user. The app should not require modification because of this change.

If you are migrating from the .NET Framework 4.0 to 4.5.1, review the following topics for application compatibility issues that may affect your app:

ADO.NET

ADO.NET now attempts to automatically reconnect broken SQL connections

ASP.NET

GridViews with AllowCustomPaging set to true may fire the PageIndexChanging event when leaving the final page of the view

Details A bug in the .NET Framework 4.5 causes PageIndexChanging to sometimes not fire for GridViews that have enabled AllowCustomPaging.
Suggestion This issue has been fixed in the .NET Framework 4.6 and may be addressed by upgrading to that version of the .NET Framework. As a work-around, the app can do an explicit BindGrid on any Page_Load that would hit these conditions (the GridView is on the last page and LastPageSize is different from PageSize). Alternatively, the app can be modified to allow paging (instead of custom paging), as that scenario does not demonstrate the problem.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

HttpRequest.ContentEncoding property prohibits UTF7

Details Beginning in .NET Framework 4.5, UTF-7 encoding is prohibited in HttpRequests’ bodies. Data for applications that depend on incoming UTF-7 data will not decode properly in some cases.
Suggestion Ideally, applications should be updated to not use UTF-7 encoding in HttpRequests. Alternatively, legacy behavior can be restored by using the aspnet:AllowUtf7RequestContentEncoding attribute of the appSettings element.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

HttpUtility.JavaScriptStringEncode escapes ampersand

IPad should not be used in custom capabilities file because it is now a browser capability

Details Beginning in .NET Framework 4.5, iPad is an identifier in the default ASP.NET browser capabilities file, so it should not be used in a custom capabilities file
Suggestion If iPad-specific capabilities are required, it is necessary to modify iPad behavior by setting capabilities on the pre-defined gateway refID “IPad” instead of by generating a new “IPad” ID by user agent matching.
Scope Edge
Version ۴٫۵
Type Runtime

Page.LoadComplete event no longer causes System.Web.UI.WebControls.EntityDataSource control to invoke data binding

Details The LoadComplete event no longer causes the EntityDataSource control to invoke data binding for changes to create/update/delete parameters. This change eliminates an extraneous trip to the database, prevents the values of controls from being reset, and produces behavior that is consistent with other data controls, such as SqlDataSource and ObjectDataSource. This change produces different behavior in the unlikely event that applications rely on invoking data binding in the LoadComplete event.
Suggestion If there is a need for databinding, manually invoke databind in an event that is earlier in the post-back.
Scope Edge
Version ۴٫۵
Type Runtime

Profiling ASP.Net MVC4 apps can lead to Fatal Execution Engine Error

Details Profilers using NGEN /Profile assemblies may crash profiled ASP.NET MVC4 applications on startup with a ‘Fatal Execution Engine Exception’
Suggestion This issue is fixed in the .NET Framework 4.5.2. Alternatively, the profiler may avoid this issue by specifying COR_PRF_DISABLE_ALL_NGEN_IMAGES in its event mask.
Scope Edge
Version ۴٫۵
Type Runtime

Sharing session state with Asp.Net StateServer requires all servers in the web farm to use the same .NET Framework version

Details When enabling StateServer session state, all of the servers in the given web farm must use the same version of the .NET Framework in order for state to be properly shared.
Suggestion Be sure to upgrade .NET Framework versions on web servers that share state at the same time.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

WebUtility.HtmlDecode no longer decodes invalid input sequences

Details By default, decoding methods no longer decode an invalid input sequence into an invalid UTF-16 string. Instead, they return the original input.
Suggestion The change in decoder output should matter only if you store binary data instead of UTF-16 data in strings. To explicitly control this behavior, set the aspnet:AllowRelaxedUnicodeDecoding attribute of the appSettings element to true to enable legacy behavior or to false to enable the current behavior.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

Core

A ConcurrentDictionary serialized in .NET Framework 4.5 with NetDataContractSerializer cannot be deserialized by .NET Framework 4.5.1 or 4.5.2

Details Due to internal changes to the type, ConcurrentDictionary<TKey,TValue> objects that are serialized with the .NET Framework 4.5 using the NetDataContractSerializer cannot be deserialized in the .NET Framework 4.5.1 or in the .NET Framework 4.5.2.Note that moving in the other direction (serializing with the .NET Framework 4.5.x and deserializing with the .NET Framework 4.5) works. Similarly, all 4.x cross-version serialization works with the .NET Framework 4.6.Serializing and deserializing with a single version of the .NET Framework is not affected.
Suggestion If it is necessary to serialize and deserialize a ConcurrentDictionary<TKey,TValue> between the .NET Framework 4.5 and .NET Framework 4.5.1/4.5.2, an alternate serializer like the DataContractSerializer or BinaryFormatter serializer should be used instead of the NetDataContractSerializer.Alternatively, because this issue is addressed in the .NET Framework 4.6, it may be solved by upgrading to that version of the .NET Framework.
Scope Minor
Version ۴٫۵٫۱
Type Runtime

Assemblies compiled with Regex.CompileToAssembly breaks between 4.0 and 4.5

BlockingCollection<T>.TryTakeFromAny does not throw anymore

Details If one of the input collections is marked completed, TryTakeFromAny(BlockingCollection<T>[], T) no longer returns -1 and TakeFromAny(BlockingCollection<T>[], T) no longer throws an exception. This change makes it possible to work with collections when one of the collections is either empty or completed, but the other collection still has items that can be retrieved.
Suggestion If TryTakeFromAny returning -1 or TakeFromAny throwing were used for control-flow purposes in cases of a blocking collection being completed, such code should now be changed to use .Any(b => b.IsCompleted) to detect that condition.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

Change in behavior for Task.WaitAll methods with time-out arguments

Details Task.WaitAll behavior was made more consistent in .NET Framework 4.5.In the .NET Framework 4, these methods behaved inconsistently. When the time-out expired, if one or more tasks were completed or canceled before the method call, the method threw an AggregateException exception. When the time-out expired, if no tasks were completed or canceled before the method call, but one or more tasks entered these states after the method call, the method returned false.

In the .NET Framework 4.5, these method overloads now return false if any tasks are still running when the time-out interval expired, and they throw an AggregateException exception only if an input task was cancelled (regardless of whether it was before or after the method call) and no other tasks are still running.

Suggestion If an AggregateException was being caught as a means of detecting a task that was cancelled prior to the WaitAll call being invoked, that code should instead do the same detection via the IsCanceled property (for example: .Any(t => t.IsCanceled)) since .NET Framework 4.6 will only throw in that case if all awaited tasks are completed prior to the timeout.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

Compiler support for type forwarding when multi-targeting mscorlib

Details A new CodeDOM feature allows a compiler to compile against the targeted version of mscorlib.dll instead of the .NET Framework 4.5 version of mscorlib.dll.
Scope Edge
Version ۴٫۵
Type Runtime

COR_PRF_GC_ROOT_HANDLEs are not being enumerated by profilers

Details In the .NET Framework v4.5.1, the profiling API RootReferences2() is incorrectly never returning COR_PRF_GC_ROOT_HANDLE (they are returned as COR_PRF_GC_ROOT_OTHER instead). This issue is fixed beginning in the .NET Framework 4.6.
Suggestion This issue has been fixed in the .NET Framework 4.6 and may be addressed by upgrading to that version of the .NET Framework.
Scope Minor
Version ۴٫۵٫۱
Type Runtime

Deserialization of objects across appdomains can fail

Details In some cases, when an app uses two or more app domains with different application bases, trying to deserialize objects in the logical call context across app domains throws an exception.
Suggestion See Mitigation: Deserialization of Objects Across App Domains
Scope Edge
Version ۴٫۵٫۱
Type Runtime

ETW EventListeners do not capture events from providers with explicit keywords (like the TPL provider)

Details ETW EventListeners with a blank keyword mask do not properly capture events from providers with explicit keywords. In the .NET Framework 4.5, the TPL provider began providing explicit keywords and triggered this issue. In the .NET Framework 4.6, EventListeners have been updated to no longer have this issue.
Suggestion To work around this problem, replace calls to EnableEvents(EventSource, EventLevel) with calls to the EnableEvents overload that explicitly specifies the “any keywords” mask to use: EnableEvents(eventSource, level, unchecked((EventKeywords)0xFFFFffffFFFFffff)).Alternatively, this issue has been fixed in the .NET Framework 4.6 and may be addressed by upgrading to that version of the .NET Framework.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

EventListener truncates strings with embedded nulls

EventSource.WriteEvent impls must pass WriteEvent the same parameters that it received (plus ID)

Details The runtime now enforces the contract that specifies the following: A class derived from EventSource that defines an ETW event method must call the base class EventSource.WriteEvent method with the event ID followed by the same arguments that the ETW event method was passed.
Suggestion An IndexOutOfRangeException exception is thrown if an EventListener reads EventSource data in process for an event source that violates this contract.
Scope Minor
Version ۴٫۵٫۱
Type Runtime

Exceptions during unobserved processing in System.Threading.Tasks.Task no longer propagate on finalizer thread

List.Sort algorithm changed

Details Beginning in .NET Framework 4.5, List<T>‘s sort algorithm has changed (to be an introspective sort instead of a quick sort). List<T>‘s sort has never been stable, but this change may cause different scenarios to sort in unstable ways. That simply means that equivalent items may sort in different orders in subsequent calls of the API.
Suggestion Because the old sort algorithm was also unstable (though in slightly different ways), there should be no code that depends on equivalent items always sorting in a particular order. If there are instances of code depending upon that and being lucky with the old behavior, that code should be updated to use a comparer that will deterministically sort the items in the desired order.
Scope Transparent
Version ۴٫۵
Type Runtime
Affected APIs

Marshal.SizeOf and Marshal.PtrToStructure overloads break dynamic code

Details Beginning in the .NET Framework 4.5.1, dynamically binding to the methods SizeOf<T>(), SizeOf<T>(T), PtrToStructure(IntPtr, Object), PtrToStructure(IntPtr, Type), PtrToStructure<T>(IntPtr), or PtrToStructure<T>(IntPtr, T), (via Windows PowerShell, IronPython, or the C# dynamic keyword, for example) can result in MethodInvocationExceptions because new overloads of these methods have been added that may be ambiguous to the scripting engines.
Suggestion Update scripts to clearly indicate which overload should be used. This can typically done by explicitly casting the methods’ type parameters as Type. See this link for more detail and examples of how to workaround the issue.
Scope Minor
Version ۴٫۵٫۱
Type Runtime

Missing Target Framework Moniker results in 4.0 behavior

Details Applications without a TargetFrameworkAttribute applied at the assembly level will automatically run using the semantics (quirks) of the .NET Framework 4.0. To ensure high quality, it is recommended that all binaries be explicitly attributed with a TargetFrameworkAttribute indicating the version of the .NET Framework they were built with. Note that using a target framework moniker in a project file will cause MSBuild to automatically apply a TargetFrameworkAttribute.
Suggestion A TargetFrameworkAttribute should be supplied, either through adding the attribute directly to the assembly or by specifying a target framework in the [project file or through Visual Studio’s project properties GUI](http://blogs.msdn.com/b/visualstudio/archive/2010/05/19/visual-studio- managed-multi-targeting-part-1-concepts-target-framework-moniker-target-framework.aspx).
Scope Major
Version ۴٫۵
Type Runtime

System.Threading.Tasks.Task no longer throw ObjectDisposedException after object is disposed

Details Except for IAsyncResult.AsyncWaitHandle, Task methods no longer throw an ObjectDisposedException exception after the object is disposed.This change supports the use of cached tasks. For example, a method can return a cached task to represent an already completed operation instead of allocating a new task. This was impossible in previous .NET Framework versions, because any consumer of the task could dispose of it, which rendered it unusable.
Suggestion Be aware that Task methods may no longer throw ObjectDisposedException in cases when the object is disposed. If an app was depending on this exception to know that a task was disposed, it should be updated to explicitly check the task’s status using Status.
Scope Minor
Version ۴٫۵
Type Runtime

System.Uri escaping now supports RFC 3986

Details URI escaping has changed in .NET Framework 4.5 to support RFC 3986. Specific changes include:
Suggestion
  • Update applications to not rely on UnescapeDataString(String) to throw in the case of an invalid escape sequence. Such sequences must be detected directly now.
  • Similarly, expect that Escaped and Unescaped URI and Data strings may vary from .NET Framework 4.0 and .NET Framework 4.5 and should not be compared across .NET versions directly. Instead, they should be parsed and normalized in a single .NET version before any comparisons are made.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

WinRT stream adapters no long call FlushAsync automatically on close

Details In Windows Store apps, Windows Runtime stream adapters no longer call the FlushAsync method from the Dispose method.
Suggestion This change should be transparent. Developers can restore the previous behavior by writing code like this:

using (var stream = GetWindowsRuntimeStream() as Stream)

// do something
await stream.FlushAsync();

Scope Transparent
Version ۴٫۵٫۱
Type Runtime

Data

ADO.NET now attempts to automatically reconnect broken SQL connections

Sql_variant data uses sql_variant collation rather than database collation

Details sql_variant data uses sql_variant collation rather than database collation.
Suggestion This change addresses possible data corruption if the database collation differs from the sql_variant collation. Applications that rely on the corrupted data may experience failure.
Scope Transparent
Version ۴٫۵
Type Runtime

SqlBulkCopy uses destination column encoding for strings

Details When inserting data into a column, SqlBulkCopy uses the encoding of the destination column rather than the default encoding for VARCHAR and CHAR types. This change eliminates the possibility of data corruption caused by using the default encoding when the destination column does not use the default encoding. In rare cases, an existing application may throw a SqlException exception if the change in encoding produces data that is too big to fit into the destination column.
Suggestion Expect that SqlBulkCopy will no longer corrupt data due to encoding differences. If strings near the destination column’s size limit are being copied, it may be necessary to either pre-encode data (to be copied to check that the data will fit in the destination column) or catch SqlExceptions.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

SqlConnection can no longer connect to SQL Server 1997 or databases using the VIA adapter

Details Connections to SQL Server databases using the Virtual Interface Adapter (VIA) protocol are no longer supported. The protocol used to connect to a SQL Server database is visible in the connection string. A VIA connection will contain via:<servername>. If this app is connecting to SQL via a protocol other than VIA (tcp: or np: for example), then no breaking change will be encountered.Also, connections to SQL Server 7 (1997) are no longer supported.
Suggestion The VIA protocol is deprecated, so an alternative protocol should be used to connect to SQL databases. The most common protocol used is TCP/IP. Instructions for enabling the TCP/IP protocol can be found here. If the database is only accessed from within an intranet, the shared pipes protocol may provide better performance if the network is slow.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

SqlConnection.Open fails on Windows 7 with non-IFS Winsock BSP or LSP present

Details Open() and OpenAsync(CancellationToken) fail in the .NET Framework 4.5 if running on a Windows 7 machine with a non-IFS Winsock BSP or LSP are present on the computer.To determine whether a non-IFS BSP or LSP is installed, use the netsh WinSock Show Catalog command, and examine every Winsock Catalog Provider Entry item that is returned. If the Service Flags value has the 0x20000 bit set, the provider uses IFS handles and will work correctly. If the 0x20000 bit is clear (not set), it is a non-IFS BSP or LSP.
Suggestion This bug has been fixed in the .NET Framework 4.5.2, so it can be avoided by upgrading the .NET Framework. Alternatively, it can be avoided by removing any installed non-IFS Winsock LSPs.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

Debugger

Null coalescer values are not visible in debugger until one step later

Details A bug in the .NET Framework 4.5 causes values set via a null coalescing operation to not be visible in the debugger immediately after the assignment operation is executed when running on the 64-bit version of the Framework.
Suggestion Stepping one additional time in the debugger will cause the local/field’s value to be correctly updated. Also, this issue has been fixed in the .NET Framework 4.6; upgrading to that version of the Framework should solve the issue.
Scope Edge
Version ۴٫۵
Type Runtime

Entity Framework

Change in behavior in Data Definition Language (DDL) APIs

Details The behavior of DDL APIs when AttachDBFilename is specified has changed as follows:

  • Connection strings need not specify an Initial Catalog value. Previously, both AttachDBFilename and Initial Catalog were required.
  • If both AttachDBFilename and Initial Catalog are specified and the given MDF file exists, the DatabaseExists method returns true. Previously, it returned false.
  • If both AttachDBFilename and Initial Catalog are specified and the given MDF file exists, calling the DeleteDatabase method deletes the files.
  • If DeleteDatabase is called when the connection string specifies an AttachDBFilename value with an MDF that doesn’t exist and an Initial Catalog that doesn’t exist, the method throws an InvalidOperationException exception. Previously, it threw a SqlException exception.
Suggestion These changes make it easier to build tools and applications that use the DDL APIs. These changes can affect application compatibility in the following scenarios:
Scope Minor
Version ۴٫۵
Type Runtime

Different exception handling for ObjectContext.CreateDatabase and DbProviderServices.CreateDatabase methods

EntityFramework 6.0 loads very slowly in apps launched from Visual Studio

Details Launching an app from Visual Studio 2013 that uses EntityFramework 6.0 can be very slow.
Suggestion This issue is fixed in EntityFramework 6.0.2. Update EntityFramework to avoid the performance issue.
Scope Edge
Version ۴٫۵
Type Runtime

Log file name created by the ObjectContext.CreateDatabase method has changed to match SQL Server specifications

Details When the CreateDatabase() method is called either directly or by using Code First with the SqlClient provider and an AttachDBFilename value in the connection string, it creates a log file named filename_log.ldf instead of filename.ldf (where filename is the name of the file specified by the AttachDBFilename value). This change improves debugging by providing a log file named according to SQL Server specifications.
Suggestion If the log file name is important for an app, the app should be updated to expect the standard _log.ldf file name format.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

ObjectContext.Translate and ObjectContext.ExecuteStoreQuery now support enum type

LINQ

Enumerable.Empty<TResult> always returns cached instance

Details Beginning in .NET Framework 4.5, Empty<TResult>() always returns a cached internal instance IEnumerable<T>.Previously, Empty<TResult>() would cache an empty IEnumerable<T> at the time the API was called, meaning that in some conditions in which Empty<TResult>() was called rapidly and concurrently, different instances of the type could be returned for different calls to the API.
Suggestion Because the previous behavior was non-deterministic, code is unlikely to depend on it. However, in the unlikely case that empty enumerables are being compared and expected to sometimes be unequal, explicit empty arrays should be created (new T[0]) instead of using Empty<TResult>().
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

Managed Extensibility Framework (MEF)

MEF catalogs implement IEnumerable and therefore can no longer be used to create a serializer

Details Starting with the .NET Framework 4.5, MEF catalogs implement IEnumerable and therefore can no longer be used to create a serializer (XmlSerializer object). Trying to serialize a MEF catalog throws an exception.
Suggestion Can no longer use MEF to create a serializer
Scope Major
Version ۴٫۵
Type Runtime

Networking

Deserialization of MailMessage objects serialized under the .NET Framework 4.5 may fail

Details Starting with the .NET Framework 4.5, MailMessage objects can include non-ASCII characters. In the .NET Framework 4, only ASCII characters are supported. MailMessage objects that contain non-ASCII characters and that are serialized under the .NET Framework 4.5 or later cannot be deserialized under the .NET Framework 4.
Suggestion Ensure that your code provides exception handling when deserializing a MailMessage object.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

System.Net.PeerToPeer.Collaboration unavailable on Windows 8

Details The System.Net.PeerToPeer.Collaboration namespace is unavailable on Windows 8 or above.
Suggestion Apps that support Windows 8 or above must be updated to not depend on this namespace or its members.
Scope Major
Version ۴٫۵
Type Runtime
Affected APIs

Printing

Data written to PrintSystemJobInfo.JobStream must be in XPS format

Details The JobStream property exposes the stream of a print job. The user can send raw data to the underlying operating system printing components by writing to this stream.Starting with the .NET Framework 4.5 on Windows 8 and later versions of the Windows operating system, data written to this stream must be in XPS format as a package stream.
Suggestion To output print content, you can do either of the following:

  • Use the XpsDocumentWriter class to output print content. This is the recommended alternative.
  • Ensure that the data sent to the stream returned by the JobStream property is in XPS format as a package stream.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

Serialization

BinaryFormatter can fail to find type from LoadFrom context

Details As of .NET Framework 4.5, a number of XmlSerializer changes may cause differences in deserialization when using BinaryFormatter to deserialize types that had been loaded in the LoadFrom context. These changes are due to the new ways XmlSerializer now loads a type which causes different behavior when a BinaryFormatter attempts to deserialize to that type later on. The default serialization binder does not automatically search the LoadFrom context, although it may have worked in some circumstances based on the old behavior of XmlSerializer. Due to the changes, when a type is being loaded from an assembly loaded in a different context, a FileNotFoundException may be thrown.
Suggestion If this exception is seen, the Binder property of the BinaryFormatter can be set to a custom binder that will find the correct type.

var formatter = new BinaryFormatter  Binder = new TypeFinderBinder() 

And then the custom binder:

public class TypeFinderBinder : SerializationBinder

private static readonly string s_assemblyName = Assembly.GetExecutingAssembly().FullName;

public override Type BindToType(string assemblyName, string typeName)

return Type.GetType(String.Format(CultureInfo.InvariantCulture, "0, 1", typeName, s_assemblyName));


Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

NetDataContractSerializer fails to deserialize a ConcurrentDictionary serialized with a different .NET version

SoapFormatter cannot deserialize Hashtable and similar ordered collection objects

XmlSerializer fails while serializing a type that hides an accessible member with an inaccessible one

Details When serializing a derived type, the XmlSerializer can fail if the type contains an inaccessible field or property that hides (via the ‘new’ keyword) a field or property of the same name that was previously accessible (public, for example) on the base type.
Suggestion This problem can be solved by making the new, hiding member accessible to the XmlSerializer (by marking it public, for example).Alternatively, the following config setting will revert to 4.0 XmlSerializer behavior, which will fix the problem:

<system.xml.serialization>
<xmlSerializer useLegacySerializerGeneration="true" />
</system.xml.serialization>
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

Web Applications

Managed browser hosting controls from the .NET Framework 1.1 and 2.0 are blocked

Details Hosting these controls is blocked in Internet Explorer.
Suggestion Internet Explorer will fail to launch an application that uses managed browser hosting controls. The previous behavior can be restored by setting the EnableIEHosting value of the registry subkey HKLM/SOFTWARE/MICROSOFT/.NETFramework to 1 for x86 systems and for 32-bit processes on x64 systems, and by setting the EnableIEHosting value of the registry subkey HKLM/SOFTWARE/Wow6432Node/Microsoft/.NETFramework to 1 for 64-bit processes on x64 systems.
Scope Minor
Version ۴٫۵
Type Runtime

Windows Communication Foundation (WCF)

Error codes for maxRequestLength or maxReceivedMessageSize are different

Details Messages in WCF web services hosted in Internet Information Services (IIS) or ASP.NET Development Server that exceed maxRequestLength (in ASP.NET) or maxReceivedMessageSize (in WCF) have different error codeThe HTTP status code has changed from 400 (Bad Request) to 413 (Request Entity Too Large), and messages that exceed either the maxRequestLength or the maxReceivedMessageSize setting throw a ProtocolException exception. This includes cases in which the transfer mode is Streamed.
Suggestion This change facilitates debugging in cases where the message length exceeds the limits allowed by ASP.NET or WCF.You must modify any code that performs processing based on an HTTP 400 status code.
Scope Edge
Version ۴٫۵
Type Runtime

MinFreeMemoryPercentageToActiveService is now respected

Details This setting establishes the minimum memory that must be available on the server before a WCF service can be activated. It is designed to prevent OutOfMemoryException exceptions. In the .NET Framework 4.5, this setting had no effect. In the .NET Framework 4.5.1, the setting is observed.
Suggestion An exception occurs if the free memory available on the web server is less than the percentage defined by the configuration setting. Some WCF services that successfully started and ran in a constrained memory environment may now fail.
Scope Minor
Version ۴٫۵٫۱
Type Runtime

System.ServiceModel.Web.WebServiceHost object no longer adds a default endpoint

Details The WebServiceHost object no longer adds a default endpoint if an explicit endpoint has been added by application code.
Suggestion If users will expect to be able to connect to a default endpoint and other explicit endpoints have been added to the WebServiceHost, default endpoints should also be added explicitly (using AddDefaultEndpoints()).
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

The Replace method in OData URLs is disabled by default

Details Beginning in the .NET Framework 4.5, the Replace method in OData URLs is disabled by default. When OData Replace is disabled (now by default), any user requests including replace functions (which are uncommon) will fail.
Suggestion If the replace method is required (which is uncommon), it can be re-enabled through a config settings (ReplaceFunction). However, an enabled replace method can open security vulnerabilities and should only be used after careful review.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

Windows Forms

PreviewLostKeyboardFocus is called repeatedly if its handler shows a Windows Forms message box

WinForm’s CheckForOverflowUnderflow property is now true for System.Drawing

Details The CheckForOverflowUnderflow property for the System.Drawing.dll assembly is set to true.
Suggestion Previously when overflows occurred, the result would be silently truncated. Now an OverflowException exception is thrown.
Scope Edge
Version ۴٫۵
Type Runtime

Windows Presentation Foundation (WPF)

Accessing a WPF DataGrid’s selected items from a handler of the DataGrid’s UnloadingRow event can cause a NullReferenceException

Calling DataGrid.CommitEdit from a CellEditEnding handler drops focus

Calling Items.Refresh on a WPF ListBox, ListView, or DataGrid with items selected can cause duplicate items to appear in the element

Details In the .NET Framework 4.5, calling ListBox.Items.Refresh from code while items are selected in a ListBox can cause the selected items to be duplicated in the list. A similar issue occurs with ListView and DataGrid. This is fixed in the .NET Framework 4.6.
Suggestion This issue may be worked around by programatically unselecting items before Refresh() is called and then re-selecting them after the call is completed. Alternatively, this issue has been fixed in the .NET Framework 4.6 and may be addressed by upgrading to that version of the .NET Framework.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

FlowDocument may show an extra line of text

GlyphRun.ComputeInkBoundingBox() and FormattedText.Extent return different values beginning in .NET Framework 4.5

Details Improvements were made to ComputeInkBoundingBox() and Extent in the .NET Framework 4.5 to address issues where the boxes were too small for the contained glyphs in some cases in the .NET Framework 4.0. As a result of this, some bounding boxes will be larger beginning in the .NET Framework 4.5, resulting in subtle differences in UI layout.
Suggestion Be aware that some glyph bounding box sizes have increased. These changes will usually improve presentation and hit box testing, but if the older (pre-.NET 4.5) behavior is desired, it can be opted into by adding the following entry to the app.config file:

<appsettings>
<add key="IncludeAllInkInBoundingBox" value="false">
</appsettings>
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

Intermittently unable to scroll to bottom item in ItemsControls (like ListBox and DataGrid) when using custom DataTemplates

Details In some instances, a bug in the .NET Framework 4.5 is causing ItemsControls (like ListBox, ComboBox, DataGrid, etc.) to not scroll to their bottom item when using custom DataTemplates. If the scrolling is attempted a second time (after scrolling back up), it will work then.
Suggestion This issue has been fixed in the .NET Framework 4.5.2 and may be addressed by upgrading to that version (or a later version) of the .NET Framework. Alternatively, users can still drag scroll bars to the final items in these collections, but may need to try twice to do so successfully.
Scope Minor
Version ۴٫۵
Type Runtime

Items.Clear does not remove duplicates from SelectedItems

Details Suppose a Selector (with multiple selection enabled) has duplicates in its SelectedItems collection – the same item appears more than once. Removing those items from the data source (e.g. by calling Items.Clear) fails to remove them from SelectedItems; only the first instance is removed. Furthermore, subsequent use of SelectedItems (e.g. SelectedItems.Clear()) can encounter problems such as ArgumentException, because SelectedItems contains items that are no longer in the data source.
Suggestion Upgrade if possible to .NET Framework 4.6.2.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

ListBoxItem IsSelected binding issue with ObservableCollection<T>.Move

New enum values in WPF’s PageRangeSelection

PreviewLostKeyboardFocus is called repeatedly if its handler shows a Windows Forms message box

Right clicking on a WPF DataGrid row header changes the DataGrid selection

Details Right-clicking a selected DataGrid row header while multiple rows are selected results in the DataGrid‘s selection changing to only that row.
Suggestion This issue has been fixed in the .NET Framework 4.6 and may be addressed by upgrading to that version of the .NET Framework.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

WPF DataTemplate elements are now visible to UIA

Details Previously, DataTemplate elements were invisible to UI Automation. Beginning in 4.5, UI Automation will detect these elements. This is useful in many cases, but can break tests that depend on UIA trees not containing DataTemplate elements.
Suggestion UI Automation tests for this app may need updated to account for the UIA tree now including previously invisible DataTemplate elements. For example, tests that expect some elements to be next to each other may now need to expect previously invisible UIA elements in between. Or tests that rely on certain counts or indexes for UIA elements may need updated with new values.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

WPF DispatcherSynchronizationContext.CreateCopy now returns a new copy instead of the current instance

Details In the .NET Framework 4, CreateCopy() returned a reference to the current instance, primarily as a performance optimization. In the .NET Framework 4.5, it returns a new instance which makes it possible for the first time to conclude that equal references indicate the executing thread is in the correct synchronization context. It is unlikely that code that checks the identity of these references will be affected, but because of the change, code that calls CreateCopy() should be tested as part of migration to the .NET Framework 4.5 or newer.
Suggestion Be aware that CreateCopy() will now return a new SynchronizationContext object. Previously, code that used equivalence of references generated this way was not actually checking whether it was in the proper context, but does when built against .NET Framework 4.5 or later. While unlikely to cause issues, exercising the affected code paths should be enough to determine if this poses any problem.
Scope Minor
Version ۴٫۵
Type Runtime
Affected APIs

WPF TextBox defaults to undo limit of 100

Details In .NET Framework 4.5, the default undo limit for a WPF textbox is 100 (as opposed to being unlimited in .NET Framework 4.0)
Suggestion If an undo limit of 100 is too low, the limit can be set explicitly with UndoLimit
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

WPF TextBox selected text appears a different color when the text box is inactive

Details In .NET Framework 4.5, when a WPF text box control is inactive (it doesn’t have focus), the selected text inside the box will appear a different color than when the control is active.
Suggestion The previous (.NET Framework 4.0) behavior may be restored by setting the AreInactiveSelectionHighlightBrushKeysSupported property to false.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

WPF TreeViewItem must be used within a TreeView

Details A change was introduced in 4.5 that restricts usage of TreeViewItem elements outside of a TreeView. This manifests under the following conditions:

  • TreeViewItem‘s visual parent is not a panel. (A TreeViewItem generated for a TreeView will have a panel as its parent)
  • The TreeViewItem is a descendant of a VirtualizingStackPanel acting as the “items host” for a list control (ListBox, DataGrid, ListView, etc.). Virtualization doesn’t need to be enabled.
  • The VirtualizingStackPanel is item-scrolling (ScrollUnit="Item").
  • Someone calls VirtualizingStackPanel.MakeVisible(v) to scroll an element v into view. This can be done explicitly, or implicitly in a number of ways; perhaps the most common way is simply clicking on v to give it the keyboard focus.
  • The visual-parent chain from v to the VirtualizingStackPanel passes through the TreeViewItem.

In other words, this is seen when a TreeViewItem is used outside of a TreeView, and the user clicks on a descendant of the TreeViewItem to bring it into view. If the TreeViewItem has no focusable descendants, you’ll never see this issue. An example of a situation where this is hit is when a TreeViewItem is the root of a DataTemplate. When this issue is hit, there is an InvalidCastException that occurs within the WPF framework.

Suggestion A hotfix will be made available for this.
Scope Minor
Version ۴٫۵
Type Runtime

Windows Workflow Foundation (WF)

System.Activities is now APTCA

WF serializes Expressions.Literal<T> DateTimes differently now (breaks custom XAML parsers)

Details The associated ValueSerializer object will convert a DateTime or DateTimeOffset object whose Second and Millisecond components are non-zero and (for a DateTime value) whose Kind property is not Unspecified to property element syntax instead of a string. This change allows DateTime and DateTimeOffset values to be round-tripped. Custom XAML parsers that assume that input XAML is in the attribute syntax will not function correctly.
Suggestion This change allows DateTime and DateTimeOffset values to be round-tripped. Custom XAML parsers that assume that input XAML is in the attribute syntax will not function correctly.
Scope Edge
Version ۴٫۵
Type Runtime

XML, XSLT

XmlSchemaException now sets line positions properly

Details If the SetLineInfo value is passed to the Load method and a validation error occurs, the LineNumber and LinePosition properties now contain line information.
Suggestion Exception-handling code that assumes LineNumber and LinePosition will not be set should be updated since these properties will now be set properly when SetLineInfo is used while loading XML.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

XmlTextReader DTD entity expansion is limited to 10,000,000 characters

Details DTD entity expansion is now limited to 10,000,000 characters. Loading XML files without DTD entity expansion or with limited DTD entity expansion is unaffected. Files with DTD entities that expand to more than 10,000,000 characters fail to load, and now throw an exception.
Suggestion If the limit of DTD entity expansion is too low 10,000,000, the value can be overridden with the MaxCharactersFromEntities property. An XmlReaderSettings with the proper MaxCharactersFromEntities value can be passed to XmlReader.Create that takes XmlReaderSettings (ie. Create(String, XmlReaderSettings))
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

XSLT forward compat now works

Details In the .NET Framework 4, XSLT 1.0 forward compatibility had the following issues:

  • Loading a style sheet failed if its version was set to 2.0 and the parser encountered an unrecognized XSLT 1.0 construct.
  • The xsl:sort construct failed to sort data if the style sheet version was set to 1.1.

In the .NET Framework 4.5, these issues have been fixed, and XSLT 1.0 forward compatibility mode works properly.

Suggestion Most apps should be unaffected, however data will be sorted differently in some cases now that xsl:sort is respected. If xsl:sort is used in 1.1 style sheets, confirm that apps were not depending on the unsorted order of data. If apps rely on the 4.0 sorting behavior, remove xsl:sort from the style sheet.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

XSLT style sheet exception message changed

Details In the .NET Framework 4.5, the text of the error message when an XSLT file is too complex is “The style sheet is too complex.” In previous versions, the error message was “XSLT compile error.” Application code that depends on the text of the error message will no longer work. However, the exception types remain the same, so this change should have no real impact.
Suggestion Update any app code depending on the exception message from this error condition to expect the new message, or (even better) update the code to depend only on the exception type (XsltException), which has not changed.
Scope Edge
Version ۴٫۵
Type Runtime
Affected APIs

[ad_2]

source_link
https://www.asp.net