Questions tagged [.net-4.0]

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

Released on April 12th, 2010, version 4.0 (4.0.30319.1) of the Microsoft .NET Framework contains numerous enhancements, new features and bug fixes.

What's New in the .NET Framework 4

Language Improvements

Base Class Library (BCL) additions:

For more information about the new features, see:

8834 questions
136
votes
4 answers

Unable to load SOS in WinDbg

Background: I'm new to WinDbg and trying to get it running for the first time. I want to examine a memory dump I took from a running ASP.NET 4 site hosted in IIS 7 on Windows Server 2008 (x86) and downloaded to my local machine. I installed the…
Kevin Babcock
  • 10,187
  • 19
  • 69
  • 89
136
votes
1 answer

Start may not be called on a promise-style task. exception is coming

I am creating a simple wpf desktop application. UI have just a button and code in .cs file like. private void Button_Click_2(object sender, RoutedEventArgs e) { FunctionA(); } public void FunctionA() { Task.Delay(5000).Start(); …
D J
  • 6,908
  • 13
  • 43
  • 75
131
votes
4 answers

Simplest way to do a fire and forget method in c# 4.0

I really like this question: Simplest way to do a fire and forget method in C#? I just want to know that now that we have Parallel extensions in C# 4.0 is there a better cleaner way to do Fire & Forget with Parallel linq?
Jonathon Kresner
  • 2,793
  • 5
  • 29
  • 40
130
votes
10 answers

C# operator overload for `+=`?

I am trying to do operator overloads for +=, but I can't. I can only make an operator overload for +. How come? Edit The reason this is not working is that I have a Vector class (with an X and Y field). Consider the following example. vector1 +=…
Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187
130
votes
7 answers

Conditional compilation and framework targets

There are a few minor places where code for my project may be able to be drastically improved if the target framework were a newer version. I'd like to be able to better leverage conditional compilation in C# to switch these as needed. Something…
mckamey
  • 17,359
  • 16
  • 83
  • 116
130
votes
5 answers

What and When to use Tuple?

May someone please explain what a Tuple is and how to use it in a Real World Scenario. I would like to find out how this can enrich my coding experience?
Donald N. Mafa
  • 5,131
  • 10
  • 39
  • 56
128
votes
6 answers

What are best practices for using SmtpClient, SendAsync and Dispose under .NET 4.0

I'm a bit perplexed on how to manage SmtpClient now that it is disposable, especially if I make calls using SendAsync. Presumably I should not call Dispose until SendAsync completes. But should I ever call it (e.g., using "using"). The scenario…
tofutim
  • 22,664
  • 20
  • 87
  • 148
127
votes
17 answers

log4net not working

Hey I have this configuration in my web.config
Jakob
  • 4,784
  • 8
  • 53
  • 79
123
votes
12 answers

How to clear MemoryCache?

I have created a cache using the MemoryCache class. I add some items to it but when I need to reload the cache I want to clear it first. What is the quickest way to do this? Should I loop through all the items and remove them one at a time or is…
Retrocoder
  • 4,483
  • 11
  • 46
  • 72
121
votes
4 answers

Installing MSBuild 4.0 without Visual Studio 2010

I installed .NET 4.0 and VS 2010 RC on my laptop and MSBuild was automatically installed. I was hoping to build a continuous integration server by just installing the .NET SDK without VS 2010, so I downloaded the .NET 4.0 Framework from Microsoft…
dewald
  • 5,133
  • 7
  • 38
  • 42
119
votes
12 answers

Problem in running .net framework 4.0 website on iis 7.0

Hey I got problem in running .NET framework 4.0 website on IIS7.0. the error I got is like: HTTP Error 404.2 - Not Found "The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server". Module…
prashant patel
  • 1,225
  • 2
  • 8
  • 7
118
votes
3 answers

How to set the maxAllowedContentLength to 500MB while running on IIS7?

I changed the maxAllowedContentLength to In my web.config, but when running on IIS7 I get this error: The…
Amr Elgarhy
  • 66,568
  • 69
  • 184
  • 301
118
votes
15 answers

Read string from .resx file in C#

How can I read a string from a .resx file in C#?
Red Swan
  • 15,157
  • 43
  • 156
  • 238
116
votes
3 answers

C# use System.Type as Generic parameter

I have a list of types (System.Type) which need te be queried on the database. For each of this types, I need to call the following extensionmethod (which is part of LinqToNhibernate): Session.Linq() However I do not have MyType, but I…
Jan
  • 9,858
  • 7
  • 26
  • 33
114
votes
7 answers

Why is there a difference in checking null against a value in VB.NET and C#?

In VB.NET this happens: Dim x As System.Nullable(Of Decimal) = Nothing Dim y As System.Nullable(Of Decimal) = Nothing y = 5 If x <> y Then Console.WriteLine("true") Else Console.WriteLine("false") '' <-- I got this. Why? End If But in C#…
blindmeis
  • 22,175
  • 7
  • 55
  • 74