Questions tagged [.net-2.0]

The 2.0 version of the .NET Framework. For questions on .NET Framework generally, use the .net tag.

The 2.0 version of the .NET Framework.

What's New in the .NET Framework 2.0
.NET Framework 2.0 System Requirements

Released by Microsoft Corporation
Version Number: 2.0.50727.42
Release Date: 2005-11-07

2578 questions
55
votes
2 answers

yield return statement inside a using() { } block Disposes before executing

I've written my own custom data layer to persist to a specific file and I've abstracted it with a custom DataContext pattern. This is all based on the .NET 2.0 Framework (given constraints for the target server), so even though some of it might look…
Neil Fenwick
  • 6,106
  • 3
  • 31
  • 38
53
votes
14 answers

InvalidOperationException: Cannot create a DbSet for 'Role' because this type is not included in the model for the context

The following solution works in .net core 1.1, but after upgrading from 1.1 to 2.0, I received the following error: InvalidOperationException: Cannot create a DbSet for 'Role' because this type is not included in the model for the context. When…
001
  • 62,807
  • 94
  • 230
  • 350
52
votes
1 answer

How to read values from custom section in web.config

I have added a custom section called secureAppSettings to my web.config file:
Manoj Singh
  • 7,569
  • 34
  • 119
  • 198
52
votes
6 answers

Get DateTime For Another Time Zone Regardless of Local Time Zone

Regardless of what the user's local time zone is set to, using C# (.NET 2.0) I need to determine the time (DateTime object) in the Eastern time zone. I know about these methods but there doesn't seem to be an obvious way to get a DateTime object for…
Dave
  • 5,436
  • 11
  • 48
  • 74
52
votes
6 answers

Get domain name

My computer is in a Domain (Active Directory) and I need to get the domain name dynamically. I found the following code on the internet: SelectQuery query = new SelectQuery("Win32_ComputerSystem"); using (ManagementObjectSearcher searcher = new…
Osvier
  • 810
  • 1
  • 8
  • 24
52
votes
6 answers

How do you provide a default type for generics?

I have a class that currently has several methods that take integer parameters. These integers map to operations that the application can perform. I'd like to make the class generic so that the consumers of the class can provide an enum type that…
Max Schmeling
  • 12,363
  • 14
  • 66
  • 109
51
votes
6 answers

How do I send ctrl+c to a process in c#?

I'm writing a wrapper class for a command line executable. This exe accepts input from stdin until I hit Ctrl+C in the command prompt shell, in which case it prints output to stdout based on the input. I want to simulate that Ctrl+C press in C#…
Kevlar
  • 8,804
  • 9
  • 55
  • 81
48
votes
7 answers

End of Stream encountered before parsing was completed?

I am trying to deserialize a stream but I always get this error "End of Stream encountered before parsing was completed"? Here is the code: //Some code here BinaryFormatter b = new BinaryFormatter(); return…
Mister Dev
  • 10,021
  • 12
  • 41
  • 33
47
votes
7 answers

Convert bitmaps to one multipage TIFF image in .NET 2.0

How can i convert an array of bitmaps into a brand new image of TIFF format, adding all the bitmaps as frames in this new tiff image? using .NET 2.0.
mirezus
  • 13,892
  • 11
  • 37
  • 42
46
votes
5 answers

Displaying thumbnail icons 128x128 pixels or larger in a grid in ListView

Original Question (see Update below) I have a WinForms program that needs a decent scrollable icon control with large icons (128x128 or larger thumbnails, really) that can be clicked to hilight or double clicked to perform some action. Preferably…
Jared Updike
  • 7,165
  • 8
  • 46
  • 72
45
votes
8 answers

Workaround for lack of 'nameof' operator in C# for type-safe databinding?

There has been a lot of sentiment to include a nameof operator in C#. As an example of how this operator would work, nameof(Customer.Name) would return the string "Name". I have a domain object. And I have to bind it. And I need names of properties…
Paul Kapustin
  • 3,297
  • 5
  • 35
  • 45
44
votes
5 answers

Compare two Lists for differences

I would like some feedback on how we can best write a generic function that will enable two Lists to be compared. The Lists contain class objects and we would like to iterate through one list, looking for the same item in a second List and report…
pedro
44
votes
5 answers

Why are some textboxes not accepting Control + A shortcut to select all by default

I have found a few textboxes here and there in my program that accepts Control+A shortcut to select the entire text "by default" with "no coding". I don't know what additional information I have to give here to enable it for all of them, as I find…
nawfal
  • 70,104
  • 56
  • 326
  • 368
44
votes
7 answers

Combine Multiple Predicates

Is there any way in c# .NET 2.0! to combine multiple Predicates? Let's say I have the following code. List names = new…
eric
  • 1,857
  • 5
  • 23
  • 33
43
votes
1 answer

Difference between EventLog.WriteEntry and EventLog.WriteEvent methods

I tried using WriteEntry and WriteEvent methods of EventLog class. EventLog.WriteEntry("Saravanan", "Application logs an entry", EventLogEntryType.Information, 2, 3); EventLog.WriteEvent("Saravanan", new EventInstance(2, 3), …
SaravananArumugam
  • 3,680
  • 6
  • 33
  • 45