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
74
votes
5 answers

Maximum value of maxRequestLength?

If we are using IIS 7 and .Net Framework 4, what will be the maximum value of maxRequestLength?
Erkan BALABAN
  • 1,347
  • 1
  • 13
  • 20
71
votes
16 answers

Things in .NET Framework 4 that every programmer should know

I recently moved to Visual Studio 2010 and upgraded my website to work with .NET Framework 4. (From VS 2008 - Framework 3.5) What are things I need to know to improve site speed, readability or memory use?
Faruz
  • 9,909
  • 10
  • 48
  • 66
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
67
votes
6 answers

Very High Memory Usage in .NET 4.0

I have a C# Windows Service that I recently moved from .NET 3.5 to .NET 4.0. No other code changes were made. When running on 3.5, memory utilzation for a given work load was roughly 1.5 GB of memory and throughput was 20 X per second. (The X…
RMD
  • 3,421
  • 7
  • 39
  • 85
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
64
votes
4 answers

Attempt by method 'System.Web.Helpers.Json..cctor()' to access method 'System.Web.Helpers.Json.CreateSerializer()' failed

I am using System.Web.Helpers.Json to deserialize some JSON into dynamic in NET 4. The following line fails with this error: TypeInitializationException: Attempt by method 'System.Web.Helpers.Json..cctor()' to access method…
wpfwannabe
  • 14,587
  • 16
  • 78
  • 129
64
votes
3 answers

Why does Enumerable.Single() iterate all elements, even when more than one item has already been found?

When profiling one of our applications, we discovered a mysterious slowdown in some code where we were calling Enumerable.Single(source, predicate) for a large collection that had more than one item that matched the predicate near the start of the…
Matthew Watson
  • 104,400
  • 10
  • 158
  • 276
64
votes
6 answers

Accessing a non-static member via Lazy or any lambda expression

I have this code: public class MyClass { public int X { get; set; } public int Y { get; set; } private Lazy lazyGetSum = new Lazy(new Func(() => X + Y)); public int Sum{ get { return lazyGetSum.Value; } } } Gives me…
Saw
  • 6,199
  • 11
  • 53
  • 104
63
votes
6 answers

Using multiple versions of the same DLL

I've been tasked in creating a new module for an application, and so, I'm adding new DLLs to the project. This is all fine and well. However, in my DLLs I'd like to use a new version of an external DLL (over which I have no control). If I just…
MBender
  • 5,395
  • 1
  • 42
  • 69
63
votes
1 answer

Difference between DeclaringType and ReflectedType

Could anyone please tell the difference between these 2 Properties? DeclaringType and ReflectedType Consider the code is: public class TestClass { public static void TestMethod() { Console.WriteLine("Method in Class",…
Khurram Hassan
  • 1,494
  • 1
  • 13
  • 21
63
votes
6 answers

IDictionary in .NET 4 not covariant

The IDictionary in .NET 4 / Silverlight 4 does not support covariance, i.e. I can't do a IDictionary myDict = new Dictionary(); analog to what I can do with IEnumerables now. Probably boils down to…
herzmeister
  • 11,101
  • 2
  • 41
  • 51
61
votes
8 answers

Should I always use Parallel.Foreach because more threads MUST speed up everything?

Does it make sense to you to use for every normal foreach a parallel.foreach loop ? When should I start using parallel.foreach, only iterating 1,000,000 items?
Elisabeth
  • 20,496
  • 52
  • 200
  • 321
59
votes
5 answers

What is the difference between Entity Framework and LINQ to SQL by .NET 4.0?

I was checking 2nd edition of Professional ASP.NET MVC and realized EF replaced LINQ to SQL. I am familiar to LINQ to SQL from the first book but I know nothing about EF. Anyway while reading the code, it seems like nothing has changed except the…
Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156
58
votes
4 answers

Why Tuple's items are ReadOnly?

I was thinking to use Tuple class to store 2 integer information (StartAddress, EndAddress) I need in my program. But I discover that Tuple items are ReadOnly, so if I need to set a value for an item, I need to re-instantiate a Tuple. What is the…
Drake
  • 8,225
  • 15
  • 71
  • 104
58
votes
5 answers

Breaking changes in .NET 4.0

There is a lot of information about new features and classes in new 4.0 however there are also changes that may affect existing applications, for example Timespan now implements IFormattable and old string.Format() with invalid options will throw…
Andrey Taptunov
  • 9,367
  • 5
  • 31
  • 44