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
12
votes
5 answers

ASP.NET 5 web application as Azure Web Role?

We have a ASP.NET 5 web application in our solution. Typically, we could right click on the Cloud Service "Roles" item and add a new role from an existing project in the solution. But it cannot identity this project as a Web Role: How are we able…
Dave New
  • 38,496
  • 59
  • 215
  • 394
11
votes
1 answer

Use .net core DLL in Framework 4.6 project

I have built a DLL in .net core 2.0 and I now want to use it in a WinForms-project using the .net 4.6.1-framework. I can reference the dll but I get a "System.IO.FileLoadException" which says that "System.Runtime, Version 4.2.0.0" could not be…
user2033412
  • 1,950
  • 2
  • 27
  • 47
11
votes
4 answers

WCF SslStreamSecurity DNS Identity Check failing for just 4.6 framework

I am working on developing a new binding for a Wcf service that is hosted in IIS, I thought I got everything working, but it turns out that the client only works when it is targetting .Net framework 4.5, if I change it to target 4.6 then I get the…
BrandonAGr
  • 5,827
  • 5
  • 47
  • 72
10
votes
5 answers

Unity Coroutine yield return null EQUIVALENT with Task async await

What is the equivalent of yield return null; in Coroutine (that run each frame at Update) in an async method ? The nearest I got to find is await Task.Delay(1);, but it DO NOT run every frame. private IEnumerator RunEachFrame() { while (true) …
Ambroise Rabier
  • 3,636
  • 3
  • 27
  • 38
10
votes
3 answers

How to add reference in VS 2015/.NET 4.6?

Has VS 2015 changed drastically on how references are added? I am doing a MVC web project. I wanted to use System.Configuration.ConfigurationManager in my .NET 4.6 application. I went to the the References node and Add Reference... and added…
Old Geezer
  • 14,854
  • 31
  • 111
  • 198
10
votes
3 answers

Intermittent crash of w3wp.exe with ThreadAbortException after .NET 4.6 upgrade

For the last couple days we have seen intermittent crashes of the w3wp.exe worker process serving the main application pool for our corporate web site. Sometimes the crashes are isolated, and IIS is able to restart the worker process successfully.…
Jordan Rieger
  • 3,025
  • 3
  • 30
  • 50
10
votes
4 answers

Thread.Abort in ASP.NET app causes w3wp.exe to crash

Please do not set duplicate flag on this qustion - it is not about "why ThreadAbortException occurs", it is about "why w3wp.exe process terminates after ThreadAbortException". Let's say we have simple web application with following code…
user2440074
10
votes
2 answers

Why Does .NET 4.6 Specific Code Compile When Targeting Older Versions of the Framework?

I have a project that targets older versions of the .NET framework (.NET 4.5.2). I installed Visual Studio 2015 (and therefore .NET 4.6 on my machine). I noticed that if I use C# language features released in .NET 4.6/C# 6, it still compiles. If…
what evAR
  • 207
  • 1
  • 11
9
votes
3 answers

How to declare a not started Task that will Await for another Task?

I've done this Unit Test and I don't understand why the "await Task.Delay()" doesn't wait ! [TestMethod] public async Task SimpleTest() { bool isOK = false; Task myTask = new Task(async () => { …
Elo
  • 2,234
  • 22
  • 28
9
votes
1 answer

Cannot set app to use system default TLS version by adding appcontext settings in web.config

According to .net guidance of TLS protocol programming, it suggests to config security via appcontext switch when your project targets on .net 4.6. This way works when add appcontext in app.config for console application. However, it doesn't work…
raychen3
  • 311
  • 1
  • 2
  • 7
9
votes
4 answers

Can MS .NET 4.6 be used with Visual Studio 2010

We are still using VS 2010 SP1 to develop a large scale LOB ASP.NET web application. The infrastructure folks are looking at pushing .NET 4.6 (and the targeting pack to devs) to the desktop and I am having trouble finding anything on compatibility…
user5495678
  • 93
  • 1
  • 4
8
votes
12 answers

DateTimePicker garbled after Windows 10 Creators Update

Application built with VS 2015, C#, Winforms, using the DateTimePicker Windows control, text is garbled after updating machines to the Windows Creators Update. Has anyone else come across this or is there any suggested work around ?
Dan
  • 126
  • 2
  • 5
8
votes
3 answers

Using string interpolation and nameof in .VS 2015 NET 4.5

I'm using things like $"hello {person}" and nameof(arg1) in my code, but on checking the project properties I'm targeting .NET 4.5. Is this okay? I thought these things were introduced in 4.6. The project builds and runs okay on my machine - but…
PeteGO
  • 5,597
  • 3
  • 39
  • 70
8
votes
1 answer

How to get declared symbol from SemanticModel for newly created class?

What is the easiest way to get an ISymbol from a ClassDeclaration that I just created? Consider the following code: AdhocWorkspace workspace = new AdhocWorkspace(); Project project = workspace.AddProject("Test",…
DeCaf
  • 6,026
  • 1
  • 29
  • 51
8
votes
2 answers

Visual Studio 2015 target framework "dotnet" vs "net452"

When creating a new Visual Studio 2015 class library (package) project, one is able to set multiple target frameworks. What is the difference between dotnet and net452? project.json: "frameworks": { "dotnet": { }, "net452": {} } Project…
Dave New
  • 38,496
  • 59
  • 215
  • 394