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
4
votes
1 answer

Could not reference F# library from C# web project in .NET 4.6?

In the past, I was used to do the reference from my C# web project to my F# library project (I wrote it), and that worked well. But now when I moved to .NET 4.6, I did the same thing, but I could not make it work. It always notified The following…
thangchung
  • 2,020
  • 2
  • 17
  • 28
4
votes
1 answer

Portable Class Library has no DataContract or Serialization functions with .NET 4.6

I just took out a brand new copy of Visual Studio 2015 on a brand new copy of Windows 10. I tried to create a simple Portable Class Library (PCL) and tried to add a simple data contract: namespace ClassLibrary1 { using…
Quark Soup
  • 4,272
  • 3
  • 42
  • 74
4
votes
0 answers

.net 4.6 and GC freeze

I had a serious problem with the performance one of my projects after installing .net 4.6. It reproduced in the following case when the program is mass data processing and large amount of memory allocated about 4 gigabytes at some point the process…
MIVer
  • 144
  • 5
4
votes
1 answer

Castle.Windsor instantiating wrong version of SqlConnection with Dapper

We're having a weird problem when using Castle.Windsor to instantiate an SqlConnection using a typed factory: The registration looks like…
Yngve B-Nilsen
  • 9,606
  • 2
  • 36
  • 50
4
votes
1 answer

"Nearest-Wins" dependency resolution and backwards compatibility

When referring to this ASP.NET github wiki page, it explains how packages of the same name (but different version) can be discarded using the "Nearest Win" scenario: Nearest wins means that the dependency resolver prefers versions that are…
Dave New
  • 38,496
  • 59
  • 215
  • 394
4
votes
1 answer

TFS 2013 won't build a .NET Framework 4.6 project

I am trying to get TFS2013 to build a .NET Framework 4.6 C# project on our build servers. I have installed the build tools and the 4.6 .NET Framework out on the build machine. I can see from the build log that the build server is actually targeting…
DoomVroom
  • 330
  • 2
  • 14
4
votes
0 answers

Visual Studio 2015, Microsoft Fakes and System.Security.Claims.Claim

I have an interface in a .NET 4.5 (not 4.6) class library, public interface IBrokenFakeInterface { Claim WhyWontItGenerateFakeOfThisInterface(); } In my unit test project (MSTest) when I have added the Fakes for the appropriate assembly…
BrettJ
  • 980
  • 8
  • 15
4
votes
1 answer

MissingRuntimeArtifactException while changing IEnumerable to IQueryable in Universal Windows

In Release mode, while changing the IEnumerable source to IQueryable using AsQueryable method which throws System.Reflection.MissingRuntimeArtifactException. This is code is working fine in Debug mode, please refer the below code snippet. …
Antony
  • 43
  • 5
4
votes
1 answer

NHibernate mapping-by-code in .NET 4.6 throws "Cannot extend unmapped class"

I have project running for several months in same NH configuration that I opened today on a clean installation of Windows (VS 2015 RC is installed, also .NET 4.6 RC is installed, but project is targeting .NET 4.5) In building of NH session factory…
3
votes
0 answers

Visual Studio 2015 Windows Application Form with SQLite

I need to create an application which needs to access basic data in a database in a simple way. So I decided to use SQLite as a database manager and Microsoft Visual Studio 2015 in order to achieve my goal. My first step was to look for some info…
3
votes
0 answers

C# WEB API project TLS 1.2 setup in IIS express

I have a WEB API project running .net 4.6.1 that I want to get TLS 1.2 working on localhost in IIS express first, and then once I get that setup correctly, I want to deploy it to our dev server running IIS 7.5 on server 2008 R2 and have TLS setup…
Billy Joe
  • 49
  • 1
  • 8
3
votes
4 answers

How to convert HTML form to C# for PayPal subscription

I have the following HTML which works well for subscription payments in my test environment.
MyDaftQuestions
  • 4,487
  • 17
  • 63
  • 120
3
votes
0 answers

How to fix "can only be called from the main thread" inside ContinueWith method

I have a problem trying to manipulate GameObjects inside the ContinueWith method of a Task instance. The code below worked pretty well until we switched to .NET 4.x in Unity 2018.2. I've searched a lot and tought I found what it seems to be a…
3
votes
1 answer

How to use library targeting Entity Framework .Net 4.6.1 with .Net Core Application

I have a repository library that I use with an MVC application. It works great without any issues. Currently, I'm building a new Client application using .Net Core. I referenced my existing repository project which has target framework 4.6.1. I can…
3
votes
2 answers

Change the timespan millisecond separator; comma(,) instead of dot(.)

I want to output a timespan in the local culture, to import it as csv in Excel. The timespan contains milliseconds. with the english culture, this means e.g. 00:00:01.2345678 with the german culture, this should be 00:00:01,2345678 (comma instead of…
HugoRune
  • 13,157
  • 7
  • 69
  • 144