Questions tagged [.net-4.5]

Version 4.5 of the Microsoft .NET Framework. Use for questions specifically related to .NET Framework 4.5. For questions on .NET Framework generally, use the .net tag.

Reference

3775 questions
79
votes
8 answers

How can I create a new instance of ImmutableDictionary?

I would like to write something like this: var d = new ImmutableDictionary { { "a", 1 }, { "b", 2 } }; (using ImmutableDictionary from System.Collections.Immutable). It seems like a straightforward usage as I am declaring all the…
Lukáš Lánský
  • 4,641
  • 3
  • 32
  • 48
79
votes
1 answer

Await operator can only be used within an Async method

I'm trying to make a simple program to test the new .NET async functionality within Visual Studio 2012. I generally use BackgroundWorkers to run time-consuming code asynchronously, but sometimes it seems like a hassle for a relatively simple (but…
William Thomas
  • 2,108
  • 3
  • 22
  • 32
74
votes
4 answers

HTTP HEAD request with HttpClient in .NET 4.5 and C#

Is it possible to create a HTTP HEAD request with the new HttpClient in .NET 4.5? The only methods I can find are GetAsync, DeleteAsync, PutAsync and PostAsync. I know that the HttpWebRequest-class is able to do that, but I want to use the modern…
The Wavelength
  • 2,836
  • 2
  • 25
  • 44
72
votes
4 answers

OWIN HttpListener not located

When I try to start : WebApp.Start(new StartOptions { Port = 9956, ServerFactory = "Microsoft.Owin.Host.HttpListener" }); I get the following exception. What could be the root cause? System.MissingMemberException was caught …
GilliVilla
  • 4,998
  • 11
  • 55
  • 96
70
votes
2 answers

Does C# 7.0 work for .NET 4.5?

I created a project in Visual Studio 2017 RC to check whether I can use new C# 7.0 language features in a .NET Framework 4.5 project. It seems to me that after referencing System.ValueTuple NuGet, new tuples are working fine. Is there anything else…
Lukáš Lánský
  • 4,641
  • 3
  • 32
  • 48
70
votes
3 answers

Create zip file from byte[]

I am trying to create a Zip file in .NET 4.5 (System.IO.Compression) from a series of byte arrays. As an example, from an API I am using I end up with a List and each Attachment has a property called Body which is a byte[]. How can I…
Justin Helgerson
  • 24,900
  • 17
  • 97
  • 124
67
votes
4 answers

WPF Programming Methodology

In my APP I'm using an API of a software that my tool is managing. I've DAL that contain 16 classes, 3 of them are singletons. I've some logic in the .cs files and XAML's off course. My question is, I see a lot of comments that an app written in…
SigmaOmega
  • 839
  • 1
  • 10
  • 13
67
votes
6 answers

Why doesn't generic ICollection implement IReadOnlyCollection in .NET 4.5?

In .NET 4.5 / C# 5, IReadOnlyCollection is declared with a Count property: public interface IReadOnlyCollection : IEnumerable, IEnumerable { int Count { get; } } I am wondering, wouldn't it have made sense for ICollection to…
Zaid Masud
  • 13,225
  • 9
  • 67
  • 88
65
votes
10 answers

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

My application connects to Experian server and Experian will soon stop supporting TLS 1.0 and TLS 1.1. All connectivity using HTTPS must use TLS Version 1.2. I want to do some research on that issue and see sending HttpWebRequest using TLS 1.2 on…
gene
  • 2,098
  • 7
  • 40
  • 98
65
votes
7 answers

TemporaryGeneratedFile_[guid] in /obj/debug breaking build

I have 3 temporary files being created in…
NikolaiDante
  • 18,469
  • 14
  • 77
  • 117
63
votes
1 answer

What can I do in C# 5 with .Net 4.5 that I couldn't do in C# 4 with .Net 4?

I have Visual Studio 2012 RC installed on Windows 8 Release Preview and my question is are there any useful new features not related to Metro, or is Metro what seperates .Net 4 and .Net 4.5?
JMK
  • 27,273
  • 52
  • 163
  • 280
62
votes
7 answers

How do I detect at runtime that .NET version 4.5 is currently running your code?

I installed .NET 4.5 Developer preview from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27541, which 'replaces' .NET 4.0 version. However, the old way to detect the .NET framework version seems to return 4.0 (more precisely…
Evereq
  • 1,662
  • 1
  • 18
  • 23
61
votes
4 answers

What are the differences between using ConfigureAwait(false) and Task.Run?

I understand that it's recommended to use ConfigureAwait(false) for awaits in library code so that subsequent code does not run in the caller's execution context, which could be a UI thread. I also understand that await Task.Run(CpuBoundWork) should…
Sam
  • 40,644
  • 36
  • 176
  • 219
55
votes
10 answers

awaitable Task based queue

I'm wondering if there exists an implementation/wrapper for ConcurrentQueue, similar to BlockingCollection where taking from the collection does not block, but is instead asynchronous and will cause an async await until an item is placed in the…
spender
  • 117,338
  • 33
  • 229
  • 351
54
votes
3 answers

Using a proxy with .NET 4.5 HttpClient

I'm troubleshooting a bug with a service I call through .NET's HttpClient, trying to route the request through a local proxy (Fiddler), but my proxy settings seem to not be taking effect. Here's how I create the client: private HttpClient…
Mike Ruhlin
  • 3,546
  • 2
  • 21
  • 31