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
113
votes
15 answers

How to flatten tree via LINQ?

So I have simple tree: class MyNode { public MyNode Parent; public IEnumerable Elements; int group = 1; } I have a IEnumerable. I want to get a list of all MyNode (including inner node objects (Elements)) as one flat list Where…
myWallJSON
  • 9,110
  • 22
  • 78
  • 149
111
votes
3 answers

HtmlString vs. MvcHtmlString

HtmlString vs. MvcHtmlString What are the differences bettween those two, or when to prefer one over the other? Edit: One thing to prefer MvcHtmlString over HtmlString is the extension method IsNullOrEmpty of MvcHtmlString.
stacker
  • 14,641
  • 17
  • 46
  • 74
110
votes
4 answers

Creating threads - Task.Factory.StartNew vs new Thread()

I am just learning about the new Threading and Parallel libraries in .Net 4 In the past I would create a new Thread like so (as an example): DataInThread = new Thread(new ThreadStart(ThreadProcedure)); DataInThread.IsBackground =…
Jon
  • 38,814
  • 81
  • 233
  • 382
108
votes
5 answers

Windows SDK 7.1 Setup failure

I am trying to install Windows SDK for Windows 7 with .NET Framework 4 but when I open the setup I receive an error: Some Windows SDK components require the RTM .NET Framework 4. Setup detected a pre-release version of .NET Framework 4. If you…
dngadelha
  • 1,314
  • 2
  • 11
  • 14
108
votes
19 answers

ComboBox- SelectionChanged event has old value, not new value

C#, .NET 4.0, VS2010. New to WPF. I have a ComboBox on my MainWindow. I hooked the SelectionChanged event of said combo box. However, if I examine the value of the combo box in the event handler, it has the old value. This sounds more like a…
Matt
  • 41,216
  • 30
  • 109
  • 147
107
votes
13 answers

VSTS 2010 SGEN : error : Could not load file or assembly (Exception from HRESULT: 0x80131515)

I am experiencing a strange issue with VS2010. We use TFS to build our API dlls and we used to reference them in our projects usign a mapped network drive that was fully trusted. We have been working like that for at least two years and everything…
Developer IT
  • 1,203
  • 2
  • 11
  • 17
105
votes
3 answers

The quest for the Excel custom function tooltip

This question has been asked before, but each time the accepted answer is simply a resignation to provide function descriptions using Application.MacroOptions (VBA6) (VBA7), but this information does not actually appear as a tooltip, so it does not…
Alain
  • 26,663
  • 20
  • 114
  • 184
103
votes
5 answers

Why can I create a class named "var"?

Isn't var a keyword in C#? But why can I do this: public class var { } public class main { public static void main(string[] args) { var testVar = new var(); } } The var that is used in the code is the var class that is declared…
John Isaiah Carmona
  • 5,260
  • 10
  • 45
  • 79
102
votes
7 answers

Is there a Task based replacement for System.Threading.Timer?

I'm new to .Net 4.0's Tasks and I wasn't able to find what I thought would be a Task based replacement or implementation of a Timer, e.g. a periodic Task. Is there such a thing? Update I came up with what I think is a solution to my needs which is…
Jim
  • 4,910
  • 4
  • 32
  • 50
98
votes
19 answers

Practical example where Tuple can be used in .Net 4.0?

I have seen the Tuple introduced in .Net 4 but I am not able to imagine where it can be used. We can always make a Custom class or Struct.
Amitabh
  • 59,111
  • 42
  • 110
  • 159
98
votes
4 answers

.NET 4.0 build issues on CI server

Anybody manage to get .NET 4.0 applications compiling on a CI server without installing Visual Studio 2010 on a CI server? No SDK exists for .NET 4.0. Have installed .NET 4.0 on CI Server. Msbuild.exe works for simple projects and give the following…
DMcKenna
  • 989
  • 1
  • 7
  • 3
97
votes
5 answers

Concurrent Dictionary Correct Usage

Am I right in thinking this is the correct use of a Concurrent Dictionary private ConcurrentDictionary myDic = new ConcurrentDictionary(); //Main thread at program startup for(int i = 0; i < 4; i++) { myDic.Add(i,…
Jon
  • 38,814
  • 81
  • 233
  • 382
96
votes
8 answers

How do I restart a WPF application?

How can I restart a WPF Application? In windows Forms I used System.Windows.Forms.Application.Restart(); How to do it in WPF?
Hooch
  • 28,817
  • 29
  • 102
  • 161
92
votes
4 answers

Convert month int to month name

I was simply trying to use the DateTime structure to transform an integer between 1 and 12 into an abbrieviated month name. Here is what I tried: DateTime getMonth = DateTime.ParseExact(Month.ToString(), "M",…
Alex Hope O'Connor
  • 9,354
  • 22
  • 69
  • 112
92
votes
7 answers

TLS 1.2 in .NET Framework 4.0

I have a Windows server 2008 R2 server running a dozen .NET Framework 4.0 WebForms applications, and I need to disable TLS 1.0 and lower. When I do that, all secure connections fail and I was forced to re-enable TLS 1.0. Is there any way to use TLS…
betagreg
  • 1,031
  • 1
  • 8
  • 9