All Questions

Tagged with
Filter by
Sorted by
Tagged with
455 votes
18 answers
1.6m views

How do I make calls to a REST API using C#?

This is the code I have so far: public class Class1 { private const string URL = "https://sub.domain.com/objects.json?api_key=123"; private const string DATA = @"...
NullVoxPopuli's user avatar
223 votes
5 answers
77k views

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

I have migrated a solution that is currently targeting .NET 4.0 in VS2010 to VS2012 and now I would like to re-target it to .Net 4.5 What I am not sure about is the NuGet packages. For example EF5, ...
Ivan Zlatev's user avatar
  • 13.1k
198 votes
2 answers
9k views

Why would finding a type's initializer throw a NullReferenceException?

This has got me stumped. I was trying to optimize some tests for Noda Time, where we have some type initializer checking. I thought I'd find out whether a type has a type initializer (static ...
Jon Skeet's user avatar
  • 1.5m
155 votes
2 answers
168k views

How does Task<int> become an int?

We have this method: async Task<int> AccessTheWebAsync() { HttpClient client = new HttpClient(); Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com"); ...
Freeman's user avatar
  • 5,741
124 votes
2 answers
85k views

How to select .NET 4.5.2 as a target framework in Visual Studio

I have installed .NET Framework 4.5.2 on Windows 8.1. But in Visual Studio 2013 I do not see the .NET Framework 4.5.2 option (see screenshot). How do I target my project for .NET 4.5.2?
IT Hit WebDAV's user avatar
104 votes
15 answers
55k views

Can Visual Studio 2012 be installed side-by-side w/ Visual Studio 2010?

Will Visual Studio 2012 interfere/break .NET 4 and/or Visual Studio 2010 if installed side-by-side on the same instance of Windows?
Chris Pietschmann's user avatar
91 votes
2 answers
47k views

What does the Microsoft.Bcl.Build NuGet package do?

I'm unable to find any documentation on this - the links from the Microsoft.Bcl.Build Nuget page don't provide much help: This package provides build infrastructure components so that projects ...
crimbo's user avatar
  • 10.8k
88 votes
6 answers
138k views

Is it possible to run a .NET 4.5 app on XP?

First, I have read the following: Connect case VS case and especially this channel9 post So, from the last bullet, I really think there is no way around this, but I had to see if I could get a ...
Justin Pihony's user avatar
87 votes
5 answers
182k views

Differences between .NET 4.0 and .NET 4.5 in High level in .NET

Eager to know Differences between .NET 4.0 and .NET 4.5 in High level in .NET and also differences in ASP.NET, C# also in these frameworks
venkat's user avatar
  • 5,678
79 votes
1 answer
148k views

Await operator can only be used within an Async method [duplicate]

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 ...
William Thomas's user avatar
75 votes
4 answers
41k views

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 ...
The Wavelength's user avatar
72 votes
3 answers
73k views

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<Attachment> and each Attachment has ...
Justin Helgerson's user avatar
63 votes
1 answer
26k views

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

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's user avatar
  • 27.7k
62 votes
7 answers
47k views

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 ...
Evereq's user avatar
  • 1,671
61 votes
4 answers
34k views

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 ...
Sam's user avatar
  • 41.5k
54 votes
5 answers
65k views

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

My actual problem is that I have encountered two versions of .NET 4.5 full setups: a (possibly) older one, which is also available when downloading SQL Server Data Tools size: 50,349,920 md5: ...
alexandrul's user avatar
54 votes
3 answers
59k views

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 ...
Mike Ruhlin's user avatar
  • 3,546
53 votes
4 answers
66k views

IList<T> and IReadOnlyList<T>

If I have a method that requires a parameter that, Has a Count property Has an integer indexer (get-only) What should the type of this parameter be? I would choose IList<T> before .NET 4.5 ...
Şafak Gür's user avatar
  • 7,185
51 votes
8 answers
68k views

Where can I download the .NET 4.5 Multitargeting Pack for my build server?

I want to build a .net 4.5/VS2012 solution in TeamCity. My builds work on the agent that has VS2012 installed, but on the agent that doesn't have VS2012, I get warnings like this: C:\Windows\...
Michael Haren's user avatar
51 votes
6 answers
30k views

NetworkStream.ReadAsync with a cancellation token never cancels

Here the proof. Any idea what is wrong in this code ? [TestMethod] public void TestTest() { var tcp = new TcpClient() { ReceiveTimeout = 5000, SendTimeout = 20000 }; tcp....
Softlion's user avatar
  • 12.4k
50 votes
7 answers
11k views

Why does List<T> implement IReadOnlyList<T> in .NET 4.5?

Why does List<T> implement IReadOnlyList<T> in .NET 4.5? List<T> isn't read only...
James Newton-King's user avatar
46 votes
1 answer
4k views

Why doesn't `IList<T>` inherit from `IReadOnlyList<T>`?

When IReadOnlyList<T> was introduced in .NET 4.5, for a moment I thought the missing part of the puzzle was finally inserted in place: a way to pass a true readonly indexable interface where ...
Lou's user avatar
  • 4,334
44 votes
11 answers
61k views

Creating Directories in a ZipArchive C# .Net 4.5

A ZipArchive is a collection of ZipArchiveEntries, and adding/removing "Entries" works nicely. But it appears there is no notion of directories / nested "Archives". In theory, the class is decoupled ...
Meirion Hughes's user avatar
42 votes
4 answers
90k views

System.Web.Http is missing after a .NET 4.5 upgrade

I've just upgraded my solution to .NETE 4.5 using Target Framework Migrator, and then the package manager console command: Update-Package -Reinstall -IgnoreDependencies In one of my projects I am ...
Kev's user avatar
  • 2,686
42 votes
3 answers
2k views

Changed behavior of string.Empty (or System.String::Empty) in .NET 4.5

Short version: The C# code typeof(string).GetField("Empty").SetValue(null, "Hello world!"); Console.WriteLine(string.Empty); when compiled and run, gives output "Hello world!" under .NET version 4....
Jeppe Stig Nielsen's user avatar
41 votes
3 answers
30k views

Creating an async method in .NET 4.0 that can be used with "await" in .NET 4.5

I have a .NET project that uses C# in .NET 4.0 and VS2010. What I would like to do is add some async overloads to my library to make doing async programming easier for users in .NET 4.5 with the ...
James Newton-King's user avatar
39 votes
7 answers
18k views

OperationContext.Current is null after first await when using async/await in WCF service

I am using async/await pattern in .NET 4.5 to implement some service methods in WCF. Example service: Contract: [ServiceContract(Namespace = "http://async.test/")] public interface IAsyncTest { ...
mdonatas's user avatar
  • 1,770
38 votes
7 answers
54k views

Decompressing password-protected ZIP files with .NET 4.5

Microsoft introduces improvements for ZIP file handling in .NET 4.5 in the System.IO.Compression namespace. Namely the classes ZipArchive and ZipFile. However, I have not yet seen a way to use native ...
SoManyGoblins's user avatar
35 votes
3 answers
21k views

Does .net 4.5 work side by side with .net 4.0?

I am interested in installing the .NET 4.5. But I have heard that it is an In-Place upgrade. Since the users at my company uses Windows XP. I can't release any client side apps that use .NET 4.5. I ...
Vaccano's user avatar
  • 80.2k
34 votes
5 answers
70k views

ConfigurationManager Class not exist on .NET 4.5 Framework

I just start working with .NET Framework 4.5 of C#. Am using Windows Form Application. I have do the needed imports such as : using System.Configuration; But actually the ConfigurationManager class ...
Hatem's user avatar
  • 589
33 votes
7 answers
177k views

There is no argument given that corresponds to the required formal parameter - .NET Error

I have been refactoring one of my old MSSQL Connection helper library and I got the following error: Error CS7036 There is no argument given that corresponds to the required formal parameter '...
Latheesan's user avatar
  • 23.7k
33 votes
2 answers
10k views

Custom awaitables for dummies

In Async/Await FAQ, Stephen Toub says: An awaitable is any type that exposes a GetAwaiter method which returns a valid awaiter. ... An awaiter is any type returned from an awaitable’s ...
Şafak Gür's user avatar
  • 7,185
31 votes
7 answers
20k views

Will .NET 4.5 introduce a new version of the CLR?

In the past not every new version of .NET came with a new version of the CLR. I know .NET 1.0, 1.1, 2.0 and 4.0 did, but .NET 3.0 and 3.5 did not. Will .NET 4.5 introduce a new CLR? And how does one ...
Michiel van Oosterhout's user avatar
30 votes
5 answers
59k views

HttpClient is not found in .NET 4.5

I am trying to use the new HttpClient in .NET 4.5, but Visual Studio complains that it doesn't exist. I have System.Net, but when I type System.Net.Http, it complains for that too. Am I supposed to ...
Joan Venge's user avatar
  • 323k
30 votes
4 answers
8k views

.NET 4.5 async await and overloaded methods

I have an async method: public async Task<UserLoginExResult> LoginExAsync(CustomTable exRequest, string language, bool throwEx = true) { UserLoginExResult result = await UserService....
JakubRi's user avatar
  • 829
30 votes
3 answers
34k views

Visual Studio "Target framework" missing

I am trying to compile my .NET Standard class library project with .NET Framework 4.5.2. However, as you can see in my screenshot, version 4.5.2 is not shown in the offered list of target frameworks: ...
famle's user avatar
  • 491
30 votes
3 answers
21k views

.NET 4.5 Bug in UserPrincipal.FindByIdentity (System.DirectoryServices.AccountManagement)

In testing our .NET 4.0 application under .NET 4.5, we've encountered a problem with the FindByIdentity method for UserPrincipal. The following code works when run in a .NET 4.0 runtime, but fails ...
Grand Avenue Software's user avatar
29 votes
3 answers
18k views

.Net 4.5 WebSocket Server Running on Windows 7?

I know the ClientWebSocket class of .Net 4.5 is not supported on Windows 7, but is it possible to create a WebSocket server running on Windows 7 using the .Net 4.5 API? To make myself clearer, ...
sternr's user avatar
  • 6,356
28 votes
6 answers
31k views

Format A TimeSpan With Years

I have a class with 2 date properties: FirstDay and LastDay. LastDay is nullable. I would like to generate a string in the format of "x year(s) y day(s)". If the total years are less than 1, I ...
Dan's user avatar
  • 9,747
28 votes
1 answer
26k views

Passing a task as parameter

I am not sure whether this is possible, so here me out: I have a sequence of action to perform multiple async Task MethodA(...) { // some code // a call to specific Async IO bound method ...
Goran's user avatar
  • 6,398
28 votes
4 answers
5k views

Prevent scrolling when mouse enters WPF ComboBox dropdown

When a ComboBox has a large number of items, its dropdown will become scrollable. When the user invokes this dropdown, and moves the mouse cursor to enter the bounds of the dropdown from the bottom, ...
JoeGaggler's user avatar
  • 1,226
27 votes
4 answers
25k views

HTTP Error 403.14 - Forbidden - MVC4 .net 4.5 bundles

I made a MVC4 application with .net 4.5 using razor engine. It works fine when run locally with visual studio. When I deploy to IIS on windows server 2008 R2(all windows updates done), it appears my ...
Kyle's user avatar
  • 33.2k
27 votes
2 answers
5k views

Does .Net 4.5 support XML 1.1 yet (for characters invalid in XML 1.0)?

This is in the context of Web Services (client end). I need to interface with a back-end system (Java) and it is a requirement to transmit some control characters in the &#14; and &#31; range. ...
RichardTheKiwi's user avatar
27 votes
2 answers
17k views

How to profile WPF 4.5 UI performance?

I'm developing a .NET 4.5 WPF app and having UI rendering performance issues. After some googling, I came across WPF Performance Suite page which describes exactly the tool I need - Visual Profiler. ...
Alexander Abakumov's user avatar
27 votes
2 answers
6k views

Task.WhenAny and Unobserved Exceptions

Let's say I have three tasks, a, b, and c. All three are guaranteed to throw an exception at a random time between 1 and 5 seconds. I then write the following code: await Task.WhenAny(a, b, c); This ...
David Pfeffer's user avatar
26 votes
2 answers
71k views

Not allowed to load assembly from network location

I've recently set up a new Windows Server 2012 R2 environment and installed Visual Studio 2012. Now I'm having a problem with multiple .NET 4.5 project's I migrated from my old server, a Windows ...
Stijn's user avatar
  • 2,030
26 votes
1 answer
12k views

Is the CallerMemberName attribute in 4.5 "able to be faked"?

So .NET 4.5 introduces the CallerMemberNameAttribute, which seems like a godsend to anyone working with WPF and implementing INotifyPropertyChanged - my question is this: Is the attribute ...
JerKimball's user avatar
  • 16.7k
26 votes
6 answers
5k views

Behaviour of List<T>.Sort in .NET 4.5 changed from .NET 4.0?

I have the following test inside a project targeting .NET 4.0: [TestFixture] public class Donkey { [Test] public void TestListSorting() { var expected = new[] {...
jonnystoten's user avatar
  • 7,075
26 votes
2 answers
19k views

Will I have any issues if I upgrade from .NET 4.0 to 4.5 [closed]

I have an existing web app using a combination of MVC and WebForms on .NET 4.0. I want to upgrade to 4.5 to take advantage of some new features in EF 5 (which require 4.5). A couple of questions to ...
just.another.programmer's user avatar
25 votes
2 answers
17k views

How to keep .Net 4.0 behavior if .Net 4.5 is installed?

We have a Windows Form application that targets .Net Framework 4.0. After installing .Net Framework 4.5, the application starts crashing. We'll have to investigate the crashes and we'll most probably ...
Sylvain's user avatar
  • 19.2k

1
2 3 4 5
21