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
43
votes
11 answers

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 from a file system, in that you can create the…
Meirion Hughes
  • 24,994
  • 12
  • 71
  • 122
43
votes
2 answers

Using .Net 4.5 Async Feature for Socket Programming

I've previously used BeginAccept() and BeginRead(), but with Visual Studio 2012 I want to make use of the new asynchronous (async, await) features in my socket server program. How can I complete the AcceptAsync and ReceiveAsync functions? using…
Daniel Eugen
  • 2,712
  • 8
  • 33
  • 56
42
votes
4 answers

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 using: using System.Web.Http.Controllers; using…
Kev
  • 2,656
  • 3
  • 39
  • 63
42
votes
1 answer

SqlDependency Losing Subscription Over Time

I've been using SqlDependency in a .NET 3.5 application for over 3 years without any problems. The scenario is as follows: Central windows service with a SqlDependency watching a table (let's call this Table A) Multiple users using a WPF…
Michael Bowersox
  • 1,471
  • 11
  • 17
42
votes
3 answers

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.0 and earlier, but gives "" under .NET 4.5 and .NET…
Jeppe Stig Nielsen
  • 60,409
  • 11
  • 110
  • 181
41
votes
3 answers

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 await keyword. Right now the methods that are being…
James Newton-King
  • 48,174
  • 24
  • 109
  • 130
41
votes
1 answer

Why doesn't `IList` inherit from `IReadOnlyList`?

When IReadOnlyList 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 previously I would have to use my own read-only interfaces…
Lou
  • 4,244
  • 3
  • 33
  • 72
41
votes
3 answers

What is the correct way to read a serial port using .NET framework?

I've read a lot of questions here about how to read data from serial ports using the .NET SerialPort class but none of the recommended approaches have proven completely efficient for me. Here is the code I am using for now: SerialPort port = new…
Yannick Blondeau
  • 9,465
  • 8
  • 52
  • 74
40
votes
1 answer

Has foreach's use of variables been changed in C# 5?

In this answer https://stackoverflow.com/a/8649429/1497 Eric Lippert says that "FYI we are highly likely to fix this in the next version of C#; this is a major pain point for developers" with regards to how the foreach loops uses the variable. In…
a_hardin
  • 4,991
  • 4
  • 32
  • 40
40
votes
1 answer

Portable Class Library in MVC 4 / Razor with Visual Studio 2012 RC?

since working with Visual Studio 2012 RC we get an HttpCompileException when using a class out of an portable class library (.net 4.5 & metro profile) within a razor view. Exception: (german to english translated on google,…
BPeter
  • 813
  • 1
  • 8
  • 8
39
votes
1 answer

Is performance hit by using Caller Information attributes?

I am trying to find ways to log method name in an efficient manner w.r.t. speed and maintainability. I guess, In .NET 4.5 Caller Information attributes are exposed just for this purpose except the speed part. I feel these are just syntactic sugars…
Imran
  • 694
  • 5
  • 12
39
votes
7 answers

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 { Task…
mdonatas
  • 1,770
  • 2
  • 15
  • 15
38
votes
1 answer

How to drop column with FluentMigrator?

I am using .Net4.5 and C#, I am working on one of database migrations using FluentMigrator. I am able to alter tables and add columns by using Alter.Table("Items").InSchema("Pricing") …
Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265
37
votes
1 answer

HttpClient.PostAsync knocks out the app with exit code 0

Everything was working today until it stopped... Below is the minimum source code (I'm using VS 2012 Update 1, .Net 4.5). When I run it, app exits upon calling client.PostAsync() and so it never reaches Console.ReadLine(). Same in debugger, no…
Maxim
  • 962
  • 2
  • 9
  • 21
37
votes
2 answers

How to update StatusStrip in Windows Forms

I am trying to update the status strip in my Windows Forms application, but nothing is being displayed. Here is my code: private void textBox1_TextChanged(object sender, EventArgs e) { lines = Regex.Split(textBox1.Text.Trim(), "\r\n"); …
Luke101
  • 63,072
  • 85
  • 231
  • 359