.net

Null in IEnumerable vs IList

Why can an IEnumerable = null be passed without error but an IList=Null will not compile? ...

How do you get the default TFS Server from Team Explorer?

A call like this requires the server name or url: TeamFoundationServerFactory.GetServer("mytfsserver"); Likewise, I can use the following to get a list of available servers or server names: TeamFoundationServer[] servers = RegisteredServers.GetServers(); string[] serverNames = RegisteredServers.GetServerNames(); But how do I get th...

Dynamic use of typeof

I'm using reflection to get the properties of an object and there's no difficulty in that but I need to make my class even more generic so basically what I'm trying to do is the following: PropertyInfo[] properties = (typeof ("ObjectName")).GetProperties(BindingFlags.Public | BindingFlags.Instance); Or something similar. Notice the us...

Why was .NET called .NET?

I always wondered why Microsoft chose such a strange, search-engine-unfriendly name for such a great platform. Couldn't they have come up with something better? Apparently the codename was NGWS: Microsoft started development on the .NET Framework in the late 1990s originally under the name of Next Generation Windows Services (...

System.IO.Ports.SerialPort - can IOCTL_SERIAL_SET_WAIT_MASK be configured?

I've been trying to learn a bit about how .Net (3.5) interacts with the Serial port through the System.IO.Ports.SerialPorts class by writing a small Windows Forms application to gather caller display data from an old external modem. I've tested that the modem supports caller display; using Putty or Hyperterminal I can configure the mode...

Catching SQL unique key exceptions in .NET

I was wondering if anyone had a more elegant way to check for unique key exceptions from SQL in .NET other than parsing the error message? Right now I am calling the sproc in SQL, then using a try catch block in .NET. In the try catch block I parse the error message and it is a Unique key error I throw an instance of a custom error to ...

.NET Process Start Process Error using credentials (The handle is invalid)

I have an Windows Form application that supplies the User Name, Domain, and Password to the StartInfo, and it throws this: System.ComponentModel.Win32Exception: The handle is invalid at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() When I allow the credentials ...

Why does using Causalities in CCR result in memory leaks?

Does anyone have information about using Causalities? I have tried unsuccessfully to use these on my project as they appeared to be causing massive memory loads. Is this unusual? Beyond the normal (aka overly simple) examples given in the documentation, there isn't a heck of a lot of information about using Causalities in CCR code. ...

C# Compiler Enhancement Suggestion

Imagine someone coding the following: string s = "SomeString"; s.ToUpper(); We all know that in the example above, the call to the “ToUpper()” method is meaningless because the returned string is not handled at all. But yet, many people make that mistake and spend time trying to troubleshoot what the problem is by asking themselves “W...

How can I use the IL generated to make decisions and look for bottlenecks?

If I look at the il produced for my C# code (I can do this using the great LINQPad tool), what should I look for to find out what may be a performance bottleneck? I have read the book Inside Intermediate Language to understand the code, but it doesn't really cover how to use this information to make decisions and thus changes. Thanks ...

.Net OwnerDraw ComboBox keyboard shortcuts

I have a .Net ComboBox where I am drawing the items using DrawMode.OwnerDrawVariable or DrawMode.OwnerDrawFixed. When I do this, the standard behavior where pressing the first letter of an item when the style is DropDownList causes the item that starts with that letter to be selected stops working. What is the correct way to enable thi...

Display lines number in Stack Trace for .NET assembly in Release mode

Is there a way to display the lines in the stack trace for the .NET assembly build/deployed in Release mode? UPDATE: My application is divided into three class library projects and one ASP.NET "website" project. The error I am trying to track down is in one of the three class library projects. I only deployed the pdb file for the cl...

WPF: Show UserControl before all bound properties are loaded.

I have one UserControl which has a ListView showing a list of Client objects. Double clicking one of the rows plays an animation and transitions to another UserControl which shows the list of accounts for that client. The second user control is bound to the Accounts property on the Client object. The list of accounts is loaded the firs...

How can I mark a form/field as "dirty" if it's databound?

If I have a databound form, how do I know if a user has modified it (either by typing text into a text box, or by selecting an item in a combobox)? I've tried hooking into my textbox's "TextChanged" event, but the problem is that, when my form participates in databinding, the "TextChanged" event fires, prematurely marking my form as "dir...

Chrome / IE8 multi-process design, is it possible in .NET?

Google Chrome and IE8 (among others) aim to provide greater reliability/stability by isolating each tab (web page) in a separate process (over-simplified, I know). This would seem to be much more heavyweight then multiple threads, but has the major benefit of a crash in one process not bringing down the whole application. It seems the ...

Delegate Usage : Business Applications

Background Given that 'most' developers are Business application developers, the features of our favorite programming languages are used in the context of what we're doing with them. As a C# / ASP.NET Application developer, I tend to only use delegates when dealing with UI events. In fact (and this is part of my inexperience showing),...

How can I add an additional item to a WPF ListBox using ItemSource?

I have a WPF form with a ListBox of items bound to a method that gets the items for the list box. What I want is an additional item at the top of the ListBox that behaves differently to the rest of the items. For example, let's say I have a list of Authors (databound to a List), and when I select an author it populates another listbox ...

How can I add a new DB row and then edit it using a GridView control?

In my application I am using a grid view control. I am creating a new empty row in my grid view control using the following code: string co = ConfigurationSettings.AppSettings["MyLogin"]; SqlConnection connection = new SqlConnection(co); connection.Open(); string sql = "insert into TeamMember_tab...

retrieving an item in a listview

I'm using ListView.GetItemAt(x,y) to retrieve an item from the ListView, but I'm not able to get the item when I set the FullRowSelect option to false. I'm not sure of how to do it in .NET 1.1. Does anyone have any pointers? Here's a code snippet: public int GetListViewSubItem(ListView listView1, Point pt) { const int LVM_FIRST ...

Enabling and Disabling a cell in a Datagridview

Hi I am using Datagridview contyrol for populating the data. I need to enable some data and disable some data based on some values dynamically !! Can anyone tell me the code to do it ? ...