Browse by Tags

A realistic log4net config
Most log4net config file examples show the simplest case. Here is a more realistic example of a production log4net config that uses multiple appenders. This comes from an ASP.NET application, but the same technique will work in a server or client application...
Google Search API fails sporadically with "502 Bad Gateway"
I heard about Google's web service interface to the search database back when it was released, but today was my first attempt to use it. I'm trying to learn python, but the SOAP toolkits for python seem to be in a state of flux so I switched back...
Web Service performance numbers--plenty fast for UI work
While designing Web Services, the question of "interface granularity" often comes up. Conventional wisdom is that Web Service calls are slow, so the interface must be quite coarse to prevent performance problems. Four years ago, a partner and...
Determine if a .NET Assembly is Release or Debug
We recently got a bug report where a tester got a Debug.Assert failure in what I thought was a Release mode build. I went over to her machine, but found I couldn't tell from the binaries if it was a Release or a Debug build. ILDASM is no help, as Debug...
ExecutionEngineException explained
Last week several of our developers, myself included, experienced repeatable crashes of our Windows Forms application with an ExecutionEngineException. MSDN describes it as "The exception that is thrown when there is an internal error in the execution...
Checking if an application is already running
Many Windows Forms applications only allow a single instance to run at a time. The following snippet is a clean way to check if your process is already running: static public bool AlreadyRunning() { string processName = Process.GetCurrentProcess().ProcessName;...
Implementing Equals in C#
While working on refactorings, I often notice domain objects that implement Equals incorrectly. Below is a sample implementation of Equals. The key points are that Equals should not throw an exception if obj is null or of the wrong type. Also note the...
Implementing IDisposable
C lasses that need explicit destruction semantics or wrap managed resource usually implement IDisposable to allow for predictable destruction outside of garbage collection. As I was just reminded by a defect in my code, all classes that implement IDisposable...
Debug only methods in C#/.NET
In Steve Maguire's Writing Solid Code , he encourages writing Debug only code that double checks complex logic. For example, Excel uses a highly optimized evaluation method. In the Debug build, there is another method that evaluates the same arguments...
Delegate and Event signatures
I'm designing the events and delegates that will be used in a real-time stock quoting application. All my delegates and events will be operating in a single process, so I'm leaning towards the following: // Instrument is a stock, Tick Message has the...
More Posts Next page »