Retargeting solution from .Net 4.0 to 4.5 – how to retarget the NuGet packages?

NuGet 2.1 offers a feature that makes this a lot simpler: just do update-package -reinstall -ignoreDependencies from the Package Manager Console. NuGet 2.0 doesn’t handle re-targeting your applications very well. In order to change your packages’ target frameworks, you must uninstall and reinstall the packages (taking note of the packages you had installed so that … Read more

Serialization breaks in .NET 4.5

In 4.5, the implementation of XmlSerializer was replaced with one that isn’t dependent on the C# compiler. While it provides better startup performance and stability, you might be running into a compatibility issue between the implementations. Can you try adding the following to your app.config file and see if that fixes the issue? <configuration> <system.xml.serialization> … Read more

Task.Yield – real usages?

When you see: await Task.Yield(); you can think about it this way: await Task.Factory.StartNew( () => {}, CancellationToken.None, TaskCreationOptions.None, SynchronizationContext.Current != null? TaskScheduler.FromCurrentSynchronizationContext(): TaskScheduler.Current); All this does is makes sure the continuation will happen asynchronously in the future. By asynchronously I mean that the execution control will return to the caller of the async method, … Read more

How to reliably detect the actual .NET 4.5 version installed?

MS recently patched .NET 4.5 to restore backwards compatibility with .NET 4.0 in some scenarios (see http://blogs.msdn.com/b/dotnet/archive/2012/10/17/net-framework-4-5-off-to-a-great-start.aspx). It’s possible that MS updated the setup with these changes (so that users upgrading to .NET 4.5 don’t run into compat trouble), though I don’t know why they wouldn’t change the version number on the setup. Also, note … Read more

Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type

The problem is that topAgents is dynamic – so your ToList() call is dynamic, and so is Select. That has issues that: you can’t use lambda expressions for dynamic calls like this; dynamic calls don’t find extension methods anyway. Fortunately, the operations don’t need to be dynamic just because the element type is dynamic. You … Read more

Is async HttpClient from .Net 4.5 a bad choice for intensive load applications?

Besides the tests mentioned in the question, I recently created some new ones involving much fewer HTTP calls (5000 compared to 1 million previously) but on requests that took much longer to execute (500 milliseconds compared to around 1 millisecond previously). Both tester applications, the synchronously multithreaded one (based on HttpWebRequest) and asynchronous I/O one … Read more

Is that possible to send HttpWebRequest using TLS1.2 on .NET 4.0 framework

Yes, it supports it but you must explicitly set the TLS version on the ServicePointManager. Just have this code run anytime (in same app domain) before you make the call to Experian: System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 Update see @iignatov ‘s answer for what you must do for framework v4.0. My code works with 4.5+

Creating Directories in a ZipArchive C# .Net 4.5

You can use something like the following, in other words, create the directory structure by hand: using (var fs = new FileStream(“1.zip”, FileMode.Create)) using (var zip = new ZipArchive(fs, ZipArchiveMode.Create)) { zip.CreateEntry(“12/3/”); // just end with “https://stackoverflow.com/” }

tech