Questions tagged [.net-4.6]

.NET 4.6 (previously called .NET 4.5.3) is the latest framework release from Microsoft. It is a followup to .NET-4.5.2 which brings new features to both infrastructure (Roslyn, the compiler as a service) and new language features for both VB.net and C#

The .NET Framework 4.6 is the next version of the .NET Framework. Up until now we have been using .NET Framework 4.5.3, however since the payload includes significant features and improvements, the release number was bumped up the to clearly communicate the magnitude of changes. Note that in the Preview release, you’ll still see instances of “4.5.3” in the .NET Framework and Visual Studio version information. These will be updating these in future releases.

There are many great features in the .NET Framework 4.6 Preview. These range from new WPF features to RyuJIT as well as productivity enhancements in Visual Studio:

.NET Language Innovation

In this release, several new C# and Visual Basic language features help reduce boilerplate and clutter in everyday code, encourage a more declarative style of programming, and bring the two languages even closer together. The features listed below will be available to both languages in the final release. A few highlights are shared below. Checkout the C# and VB Team blogs for all the details.

  • Methods, getter-only properties etc. can now have a single expression as their body, just like lambdas.
  • Nameof provides a refactoring-safe way of getting the name of e.g. a parameter, member or type as a string.
  • Auto-properties can have initializers and no longer require setters.
  • Index initializers Inside an object initializer you can now initialize a specific index of the new object. C# only.
  • Exception filters let you look at an exception and decide whether to catch it with a given catch block.
  • Using null-conditional operators you can get a built-in null check while accessing and invoking members and indexers.
  • Using clauses for static classes bring their static members directly into scope, so you can. call e.g WriteLine() or Sqrt() without prefixing with the class name.
  • Await now works in catch and finally blocks, obviating some very tricky workarounds.
  • String interpolation: String interpolation provides a concise way of describing string templates that insert expressions into format strings (C# only at Preview, both VB and C# at RTM).

WPF Improvements and Roadmap

WPF has key improvements in this release:

  • Transparent child windows
  • Multi-image cursor files
  • Re-designed Blend experience
  • New set of Visual Diagnostics tools
  • Timeline tool in the Performance and Diagnostics hub

Windows Forms High DPI

Windows Forms High DPI support has been updated to include more controls. The .NET Framework 4.5.2 included high DPI support an initial set of controls.

This feature has been expanded to include: DataGridView, ComboBox, ToolStripComboBox, ToolStripMenuItem, Cursor, DomainUpDown, NumericUpDown, DataGridViewComboBoxColumn, DataGridViewColumn and ToolStripSplitButton types.

This is an opt-in feature. To enable it, set the EnableWindowsFormsHighDpiAutoResizing element to true in the application configuration (app.config) file:

<appSettings>
   <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>

Next Generation JIT Compiler -- RyuJIT

This release includes a new version of RyuJIT, the 64-bit JIT Compiler. It is enabled by default for 64-bit processes.

  • Correctness – We’ve been focusing on fixing correctness bugs, using various Microsoft cloud workloads to validate RyuJIT. This approach has been working well, since the Microsoft cloud is a very heavy user of .NET.
  • Real-World Throughput – The Bing team recently started using RyuJIT on some of their search-related workloads. Based on their initial experiments, they have seen a 25% improvement in startup time, which is a significant win.
  • SIMD Improvements – We created the SIMD .NET library in unison with RyuJIT so that RyuJIT could optimize the SIMD types. Lately, we’ve been tuning our use of registers in the RyuJIT SIMD optimizations. CPUs can crunch numbers much faster in registers, since they are effectively memory on the CPU.

While the attempt to transition to the new JIT compiler as transparent as possible, there still may be compatibility issues. If your application produces an undesired behavior on RyuJIT, you can try disabling RyuJIT, which switches your application back to using the previous JIT to determine if the problems you are seeing are caused by RyuJIT.


CLR Performance Improvements

The assembly loader now uses memory more efficiency by unloading IL assemblies after a corresponding NGEN image is loaded. This change is a major benefit for virtual memory for large 32-bit apps (such as Visual Studio) and also saves physical memory.


Support for converting DateTime to or from Unix time

New methods have been added to support converting DateTime to or from Unix time. This can be necessary, for example, when converting time values between a JavaScript client and .NET server. The following APIs have been added to DateTimeOffset.

static DateTimeOffset FromUnixTimeSeconds(long seconds)
static DateTimeOffset FromUnixTimeMilliseconds(long milliseconds)
long ToUnixTimeSeconds()
long ToUnixTimeMilliseconds()

ASP.NET Model Binding supports Task returning methods

ASP.NET Model Binding methods that were previously returning Task were not supported and threw an exception at runtime. With .NET Framework 4.6, if applications are deployed with such methods, these methods will now be executed correctly.0


Channel support for managed EventSource instrumentation

You now can use .NET EventSource instrumentation to log significant administrative or operational messages to the event log, in addition to any existing ETW sessions created on the machine

438 questions
7
votes
1 answer

Referencing Framework 4.6 Library in in .NET Core App 1.0.0 project

I'm been investigating options available to me for referencing existing .NET Framework 4.6 libraries in new .NET Core App projects. As a proof of concept I've built a very simple .NET Framework 4.6 library, published it as a NuGet package and…
kh25
  • 1,238
  • 1
  • 15
  • 33
7
votes
1 answer

XAML 2009 and .NET 4.6/Windows 10

WPF never ended up supporting XAML 2009, which is a shame because it added some useful extensions, such as generic type parameters and complex x:Key values. UWP seems to have built upon WPF. Does it, or anything else in .NET 4.6/Windows 10 support…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
7
votes
1 answer

System.Numerics.Vectors.Vector is missing

I'm studying examples of SIMD operations in C# and want to try some exapmles. I downloaded NuGet package System.Numerics.Vectors v4.0, and want to reproduce examples from the internet. But they doesn't work because this library doesn't contain class…
Alex Zhukovskiy
  • 9,565
  • 11
  • 75
  • 151
6
votes
1 answer

F# generic units in parameters defined in terms of each other

I am having trouble with F# Units of Measure when defining an operator that has a parameter with a generic unit of measure defined in terms of the generic unit of measure from another parameter. For example: type Quotient<[]'b> = |…
Aaron M. Eshbach
  • 6,380
  • 12
  • 22
6
votes
2 answers

ASP.NET Middleware doesn't preserve culture anymore

Given asp.net 4 with mvc 5.2.3 and .net 4.6.1 I want to change the CurrentCulture support globalization based on some request related things like the host. A Owin-Middleware which sets a culture. Simplified Version which produces the behavior: …
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
6
votes
2 answers

.net 4.6 framework is inplace upgrade then how is the .net framework 4.5 works in vs2015?

.net 4.6 framework is inplace upgrade then how is the .net framework 4.5 works in vs2015? I see only one folder v4.0.30319 . How is the dll stored and where ?
Rohit Sharma
  • 179
  • 1
  • 3
  • 18
6
votes
1 answer

How do I reference a UWP+NET46 portable library from a .NET 4.6 console application?

I have a portable class library project that targets .NET 4.6 and Universal Windows Platform. This class library contains just one class with the following line of code in its constructor: Directory.CreateDirectory(Path.Combine(Path.GetTempPath(),…
6
votes
5 answers

Error string encoding (Windows 10 + Visual Studio 2015 + Net 4.6)

My code: Keys = new Dictionary(); Keys.Add("Набег_0", "raid_0"); When I get Keys.ElementAt(0), I have this: {[Íàáåã_0, raid_0]}. Of course, when I run the program, key = "Набег_0" is not defined and the program crashes with a…
6
votes
1 answer

AutoFixture cannot create Claim (with .NET Framework 4.6)

I've just installed VS2015, which at the same time installed .NET Framework 4.6, and suddenly AutoFixture 3.30.8 is unable to create a Claim object. I'm guessing having the new .NET Framework version 4.6 is causing some issue inside AutoFixture. I…
demoncodemonkey
  • 11,730
  • 10
  • 61
  • 103
5
votes
0 answers

How to make SameSite Cookie Support In ASP.NET 4.6.1 and below version

I have developed a site using asp.net M V C we did ran a scan on site and it gives a C S R F asking to make the site cookies Same site. tried below code in web.config but seems its works only from 4.7.1 on wards - Is there any way we can achieve…
rohit jena
  • 51
  • 1
  • 2
5
votes
0 answers

Why is the BaseType of a Generic Type Definition not itself a Generic Type Definition when possible?

In the example below, I'm trying to understand why the BaseType is not a generic type definition and more generally, why it isn't just equal to the typeof(List<>) public class MyList : List { } // this is true by…
Suraj
  • 35,905
  • 47
  • 139
  • 250
5
votes
0 answers

WindowsIdentity.Impersonate throws ''Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))' after April 2018 (1803) update

Our installer app uses the following code to verify service account permissions: try { using (svcIdentity.Impersonate()) { using (SqlConnection conn = new SqlConnection(builder.ConnectionString)) // <<< { …
flip
  • 1,271
  • 14
  • 28
5
votes
0 answers

Enterprise library 6.0 configuration editor for Visual studio 2017

For our new project(Using Visual Studio 2017 and .net Framework 4.6), a decision has been taken to use Enterprise Library 6.0 for Logging, Exception Handling and DB access. I have a lot of resources/materials available on Internet on how to use it.…
Thavudu
  • 235
  • 3
  • 13
5
votes
2 answers

Can you install .NET 4.5 on Windows Server 2016?

I'm trying to setup an app on an Azure instance that another developer created. I'm trying to user a service that looks like it requires .NET 4.5 and is not compatible with 4.6... for some reason. The instance he setup is on Windows Server 2016,…
cnak2
  • 1,711
  • 3
  • 28
  • 53
5
votes
2 answers

Signalr - endless $.connection.hub.disconnected event?

I'm using Signalr 2.2.1 with a successful websocket connection. Here are the events for different states : ( simplified for brevity) var hub = $.connection.moveShapeHub; $.connection.hub.start().done(function () { console.log("hub started…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792