Platform type observations..

Recently someone informed me that the TAPI wrappers (ITAPI3 and ATAPI) do not appear to function properly on the Win64 platform.  It throws an exception that says: "Could not load file or assembly 'ITapi3, Version=, Culture=neutral, PublicKeyToken=36377d9f6f1f4883' or one of its dependencies. An attempt was made to load a program with an incorrect format." Now, as most know, .NET code compiles to an Intermediate Language (IL) which is a bytecode that is translated to the … [Read more...]

Implementing disposable components

A few months ago, I ran into a really weird bug with the System.Net.NetworkInformation.Ping class.  I was using it to monitor the network connectivity to a server and as my program ran, it appeared to leak handles.  I was calling Dispose (as I should) but it was still appeared to be leaking handles when called over and over.  Here's the basic code I was running (simplified for this example): Ping icmp = new Ping();icmp.PingCompleted += delegate(object sender, … [Read more...]

Remember to unregister your anonymous delegate!

I love anonymous delegates - I think they are extremely useful and allow me to solve some problems in very elegant ways.  However, once you really get into them, you start to see the dark side of anonymous delegates and that is unregistration. Here's the basic problem: when binding an instance delegate to an event to handle some activity, the delegate will cache off the instance reference - thereby keeping the reference alive.  So for example, if I had a form which wanted to … [Read more...]

Handling “Unhandled Exceptions” in .NET 2.0

I got hit with this problem from two separate clients last week - a .NET 1.1 application ported to .NET 2.0 is now terminating abruptly for no apparent reason.  Well, of course there's a reason - and it's that both applications had "hidden" exceptions being thrown in some background thread that weren't being caught.  Under .NET 1.1, the CLR would print any exceptions that occurred on threadpool threads to the console and then return the thread to the pool.  In addition, the … [Read more...]

Unknown new VS.NET 2005 feature – Calling Delegate.Invoke directly

So, at the GNET2 last week, I found out that you can now call Delegate.Invoke instead of using the C# functor syntax.  This makes code much more readable IMO -- delegate void MyCallback(string msg);...MyCallback callback;...callback += delegate(string msg) { Console.WriteLine(msg); };...callback.Invoke("Hello");   // instead of callback("Hello"); Very nice. … [Read more...]