Generic list and powershell

I met with an accident recently riding my motorcycle and hence was unable to blog for some time. Here is my post after a brief break.   I wanted to create a generic list of my class in power shell. It was an interesting experience. Here is what I found.   When I tried to create a…


Debug .NET Framework Source Code and loading SOS in Visual Studio

I found this blog post from Shawn Burke to be very useful. Comes in handy if you have to step through .NET source when debugging. Another helpful post is to load sos from Visual Studio which is explained here:


Asynchronous delegates and callback

I was debugging some issue related to asynchronous delegates and wanted to share that information with everyone.   When you do a BeginInvoke the delegate is invoked on a thread from the thread pool and on completion the callback is also called on the same thread pool thread. Now, any exceptions that is thrown on…


System.Data.DataException and System.Data.DataSet.RaiseMergeFailed exception

This was another interesting issue I encountered recently. The error presented itself as an event log entry from our logging as below:   Unhandled Exception: System.Data.DataException: <target>.Column2 and <source>.Column2 have conflicting properties: DataType property mismatch.    at System.Data.DataSet.RaiseMergeFailed(DataTable table, String conflict, MissingSchemaAction missingSchemaAction)    at System.Data.Merger.MergeSchema(DataTable table)    at System.Data.Merger.MergeTableData(DataTable src)    at System.Data.Merger.MergeDataSet(DataSet source)…


CString and GetLength

I ran into this problem recently when debugging some native code and thought that it will be good to share this with everyone.   CString sampleString = CString(_T(“Sample\0String”), 14); int len = sampleString.GetLength();          // len is 14 CString trimmedString = sampleString.Trim(); // trimmedString = “Sample” CString newstring = CString(sampleString);   // newString = “Sample” len…


NTSD and SOS: StopOnException

using System; class Program {     static void Main(string[] args)     {         Program p = new Program();         p.ExceptionSample();     }       private void ExceptionSample()     {         int i=0;         while (i < 100)         {             if (i == 60)             {                 try                 {                     throw new ArgumentException();                …


XMLSerializer, XDocument and LINQ

I took the sample from my previous post and wanted to use LINQ to query the XML. You can pretty much use the power of SQL on the document object to richly query for things you are looking for.   using System; using System.Linq; using System.Xml.Linq; using System.Collections.Generic; using System.Xml; using System.Xml.Serialization; using System.IO;  …


XmlSerialization to generate and consume XML

I want to talk about Xml Serialization this month. One of the work I was involved in recently required generation of XML and a I came across this wonderful technology which helps you generate and consume XML seamlessly.   If you are generating XML in a clumsy way using printf containing the XML tags, I…


Simple sample for Events and Delegates

I wanted to write a small sample to illustrate events and delegates. Here is a compact sample that illustrates it.   using System; public class EventSample {     public delegate void EventHandler();     public event EventHandler myeh;       public void Method()     {         Console.WriteLine(“Inside Sample Method … “);     }       public…


DBNull and Nullable types

When we have C# code interacting with the data base you run into this problem. Let me try and explain it. The database has nullable columns and C# has nullable types. For example, let us take a table Employee which has Id (int), name (string) and age (int). Let us assume that age will be…