From Wikipedia: “A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does”. Deadlocks are terribly difficult to find and even more difficult to debug. Debug Inspector is a free tool that allows you to view the call stacks of multiple threads at the same time, plugs in to the internals of the CLR and automatically detects deadlocks.

 

The most powerful feature of this tool is that it works on both managed and unmanaged code. It is actually a Visual Studio extension which can be used to detect managed deadlocks and a standalone executable to detect unmanaged deadlocks. Besides detecting deadlocks, there are more features to this tool:


Continue Reading...

Today I am going Alvin Ashcrafts and Chris Alcocks way and publish a lists of blog posts I liked. I don’t tend to do this a lot and actually, this is only the second time. So, here is the list of posts which I liked reading and wanted to share with you:

  1. Do NOT Explicitly Use Threads for Parallel Programming – Daniel Moth advise us to never explicitly use threads for parallelism, but to partition our work into many small chunks in another way.
  2. An easy and efficient way to improve .NET code performances – Patrick Smacchia present an efficient optimization on something we all use massively: loops on collections.

Continue Reading...

Is it OK to throw exceptions from constructors? Some of us may have heard that it is wrong but don’t really remember why. There are lots of philosophical arguments about this question, you may become confused trying to understand what’s the right thing to do. Does it mater if we are developing with C++ or any other .Net language like C#? I am writing this article to shed some light on the “throwing exceptions from constructors” topic. 

 

Constructors can’t return values, so we pretty much have to throw an exception to indicate that the object couldn’t be constructed. Some of you may grasp that constructors are supposed to handle simple tasks…


Continue Reading...

shootinfoot

This is part B of the 10 Ways To Programaticly Shoot Yourself In The Foot article. As I already stated in part A, there are several things a software developer can do to make his life much more difficult in the future. In this article I will talk about another 5 issues that even the best developers have to be aware of. In other words, I will try to prevent you from programaticly shooting yourself in the foot.


  • Use The Wrong Access Modifiers 

There are four access modifiers: public, protected, internal and private. Don’t use public everywhere you can! Choose the correct access modifier!…


Continue Reading...

For the last month, I was working on an imagery infrastructure library. Some of my effort was to well document each class, method and property so that the users of this library will have the privilege of knowing how to properly use it. During the development phase, I created a test project so I will be able to test my code at runtime. By the end of this month, I decided to separate the test project from the main solution and create a test solution. Surprisingly, when browsing the test code and hovering my library classes and methods, no comments appeared in the Visual Studio tooltip:

image

Those comments did appear when the test and the imagery infrastructure projects belonged to the same solution. On In this article, I am going to explain why it is so important to generate XML documentation file for each one of your .Net projects.


Continue Reading...

shootinfoot

There are several things a software developer can do to make his life much more difficult in the future. One day, some pieces of an old code may make us sorry we haven’t dedicated some more effort when we wrote it, so we have to pay attention and be careful. I am not talking about bad developers who always generate bad code because in those cases, every piece of their code is a disaster. Amit is talking about this issue in Terrible Code Examples – Methods From Hell. In this article I will point out some more .NET advanced issues that even the best developers have to be aware of. There are some things you can do which will cause some problems later on and you will be the one who have to handle with those issues. In other words, I will try to prevent you from shooting yourself in the foot.


Continue Reading...

After publishing the How To Get Free Disk Space And Other WMI Stuff (.NET) article, I learned two new things. One is about a better way to get free disk space and the other is about a better and easier way to use WMI in general. This is what is good about blogging, you share your knowledge and then learn from others.

 

Better Method For Getting Free Disk Space

Karl Agius left the following comment:

“I agree that WMI is extremely powerful, and that it lets you get to details that are not otherwise available in managed code. In this case though, the free drive space can be derived through the AvailableFreeSpace method in DriveInfo. What are the arguments for using WMI instead of this?

Great article, by the way :D That WMI object browser looks handy … sure beats trawling through MSDN looking for stuff ;) Thanks!”


Continue Reading...

I guess that most of you have already heard about Anders Hejlsberg introduction to the future of C#, taken place at PDC 2008. One of the core features introduced in C# 4.0 is called Dynamic Lookup which allows a unified approach to invoking things dynamically. Currently, when you call object methods or properties, the compiler checks that they exist and raises an error if they do not. With dynamic lookup, you can call any method or property, and they are not checked until runtime. C# 4.0 is extending towards the dynamic languages. Having an object, you do not need to worry about whether it comes from COM, Python, JavaScript or reflection, you just apply operations to it and leave it to the runtime to figure out what exactly those operations mean.


Continue Reading...

I am currently working on a SaveAs feature to some special file formats, those files are very very big. Before actually saving the file, I need to compute its anticipated size and compare it with the free disk space to see if there is enough storage for that operation. After searching a bit about how to get the free disk space, I came across the solution which uses the System.Management namespace. This namespace provides access to a rich set of management information about the system, devices, and applications instrumented to the WMI infrastructure. But, what the hell is WMI?

wmi

WMI is Windows Management Instrumentation and is part of the Windows operating system that provides management information and control. WMI provides extensive instrumentation to accomplish almost any management task and help us obtain information about our system. Applications and services can query for interesting management information such as how much free space is left on the disk, what is the current CPU utilization, which database a certain application is connected to, and much more, using classes from the System.Management namespace. Here is the MSDN page about the Windows Management Instrumentation.

Let me show you how to query the free disk space using WMI:


Continue Reading...

small_flagsUntil a couple of years ago, most software applications were released in English. Unfortunately for us the developers, nowadays, many customers require that that the product they purchased, will be localized to a specific language (other than English). I know, for instance, that there is a European law which requires healthcare products to be localized to the European market (starting from 2009 or 2010). Because this article is about how to localize your application using string tables, I recommend you to first read about a free tool which helps you extract hard coded strings to string tables. Don’t go any further before you also read about how to generate public properties for string tables, you must read it.

Setting up a String Table

I assume that you already have some user interface which needs to be localized, I will demonstrate this process with…


Continue Reading...