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.
.net-4.5
3,925
questions
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\...
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....
51
votes
7
answers
18k
views
Awaiting Asynchronous function inside FormClosing Event
I'm having a problem where I cannot await an asynchronous function inside of the FormClosing event which will determine whether the form close should continue. I have created a simple example that ...
50
votes
6
answers
32k
views
Task.Yield - real usages?
I've been reading about Task.Yield , And as a Javascript developer I can tell that's it's job is exactly the same as setTimeout(function (){...},0); in terms of letting the main single thread deal ...
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...
47
votes
5
answers
35k
views
MSBuild deploy failing after upgrade to .NET 4.5
We recently upgraded our VS 2010 and .NET 4 application to VS 2012 and .NET 4.5. We have a build script to deploy the application on the test server. We have two boxes - one is Windows 8 with VS 2012 (...
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 ...
45
votes
3
answers
28k
views
Brief explanation of Async/Await in .Net 4.5
How does Asynchronous tasks (Async/Await) work in .Net 4.5?
Some sample code:
private async Task<bool> TestFunction()
{
var x = await DoesSomethingExists();
var y = await ...
45
votes
9
answers
18k
views
Visual Studio keeps overwriting NewtonSoft.Json.DLL with an older version
Visual Studio is overwriting the correct version of NewtonSoft.Json.DLL that I have configured in both my project references and the NuGet package file with an older version when I build any other ...
45
votes
4
answers
32k
views
Entity Framework - Migrations - Code First - Seeding per Migration
I am looking into Migrations in an effort to clean up our deployment processes. The less manual intervention required when pushing a change to production the better.
I have run into 3 major snags ...
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 ...
44
votes
4
answers
37k
views
EF5 Starting a Project:Error Running transformation: Please overwrite the replacement token '$edmxInputFile$'
I'm creating a Console Project in VS2012 with .Net4.5.
After it I "Add", "New Item" to the project, and choose "EF 5.x DbContext Generator".
Then, after a couple of seconds the following error message ...
43
votes
2
answers
48k
views
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 ...
43
votes
6
answers
15k
views
Writing to ZipArchive using the HttpContext OutputStream
I've been trying to get the "new" ZipArchive included in .NET 4.5 (System.IO.Compression.ZipArchive) to work in a ASP.NET site. But it seems like it doesn't like writing to the stream of HttpContext....
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 ...
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....
42
votes
1
answer
2k
views
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 ...
41
votes
3
answers
183k
views
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 ...
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 ...
40
votes
1
answer
9k
views
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 ...
40
votes
1
answer
6k
views
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 ...
40
votes
1
answer
7k
views
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 ...
39
votes
1
answer
14k
views
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 ...
39
votes
1
answer
17k
views
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")
....
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
{
...
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 ...
37
votes
3
answers
27k
views
What happened to regtlibv12?
I have a clean install of Windows 8 on a partition, with Visual Studio 11/2012 Professional installed and I cannot find regtlibv12.exe inside C:\Windows\Microsoft.NET\Framework\v4.0.30319.
Below is a ...
37
votes
2
answers
64k
views
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 = ...
36
votes
3
answers
40k
views
Using Async Await keywords with Dapper
I want to use a micro-orm and decided to go with Dapper.
But can't seem to find any mentions of it supporting the new async/await syntax. Async queries are important for me.
Can someone provide a ...
35
votes
2
answers
50k
views
Serialization of Entity Framework objects with One to Many Relationship
I am attempting to use EF with Code First and the Web API. I don't have any problems until I get into serializing Many-to-Many relationships. When I attempt to execute the following web api method ...
35
votes
2
answers
68k
views
How to determine a 404 response status when using the HttpClient.GetAsync()
I am trying to determine the response returned by HttpClient's GetAsync method in the case of 404 errors using C# and .NET 4.5.
At present I can only tell that an error has occurred rather than the ...
35
votes
4
answers
14k
views
Include NuGet packages in TeamCity
I recently started using NuGet to manage external packages. For now I have only needed it for NLog.
Everything works fine when I Build the project in VS 2012. However, I am trying out TeamCity as a ...
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 ...
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 ...
34
votes
2
answers
46k
views
Using WebSocket on Windows 7
I just installed Visual Studio 2012 RC and tried to run a service with netHttpBinding enabling WebSocket and get the following error:
This platform does not support server side WebSockets.
The ...
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
'...
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 ...
32
votes
2
answers
24k
views
.NET 4.5 file read performance sync vs async
We're trying to measure the performance between reading a series of files using sync methods vs async. Was expecting to have about the same time between the two but turns out using async is about 5.5x ...
32
votes
2
answers
45k
views
"await" doesn't wait for the completion of call
I'm building a Metro App.
In the MainPage.xaml.cs, I instantiate Album as follows:
Album album = new Album(2012); //With the album ID as its parameter.
ListView1.ItemsSource = album.Songs;
In the ...
31
votes
12
answers
42k
views
Entry point was not found exception
I have installed vs2012 (11.0.50727.1),
I opened a new MVC4 with .NET 4.5 solution,
i create a simple HomeController and as I've wanted to start it locally, i have received this very strange error:
...
31
votes
2
answers
53k
views
DelegatingHandler for response in WebApi
I am currently using several delegation handlers (classes derived from DelegatingHandler) to work on the request before it is sent, for things like validating a signature etc. This is all very nice, ...
31
votes
5
answers
27k
views
Upgrading to .NET 4.5: An ItemsControl is inconsistent with its items source
I'm building an application, which uses many ItemControls(datagrids and listviews). In order to easily update these lists from background threads I used this extension to ObservableCollections, which ...
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 ...
31
votes
5
answers
58k
views
App_Start Folder in ASP 4.5 only in WebApplications Projects?
I have a Website Project I've converted to .NET 4.5. I'd like to use the AuthConfig that I've seen added to the App_Start directory. A couple of questions.
Is the App_Start directory only available ...
30
votes
4
answers
44k
views
asp.net 4.5 custom membership provider configuration throws strange exception [duplicate]
My web site was initially written in MVC 4.0 RC using VS2010, .
I have just downloaded and installed VS2012, and upgraded my project to Dotnet Framework 4.5.
In my project I'm using a Custom ...
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 ...
30
votes
4
answers
20k
views
Can anyone spot why I keep getting this error testing the EF 5 beta
Installed visual studio 11 beta as wanted to test EF 5 beta but keep hitting this an error.
Method not found: 'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(...
30
votes
1
answer
28k
views
HttpClient: How to upload multiple files at once
I am trying to upload muliple files using System.Net.Http.HttpClient.
using (var content = new MultipartFormDataContent())
{
content.Add(new StreamContent(imageStream), "image", "image.jpg");
...
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....
30
votes
3
answers
16k
views
How to use await on methods in interfaces
When implementing against an interface (because of mocking, remoting or similiar) using the await keyword and having an interface with methods returning Task<> :
interface IFoo
{
Task<...