Managed/Native Debugging in C#/C++

I had a problem debugging my solution consisting of C#, C++/CLI, and native C++ projects. I was not able to get breakpoints working in the native C++ parts – after running the solution with breakpoints set, they were turning gray with warning sign, and their tooltip stated that “The breakpoint will not currently be hit. No symbols have been loaded for this document.” despite all debug properties were set right on those projects and all debugging symbols existed. After fighting it for a few hours and almost giving up, I started to think that the problem might not be with the native C++ projects, but rather somewhere else, e.g. in the StartUp project, which is C#. Checked that project’s properties, and guess what! Debug > Enable unmanged code debugging option was off!!! Switched it on, and voila – breakpoints work fine in native C++ DLL now!!! :)

Threading in C#

Joseph Albahari, the author of C# 3.0 in a Nutshell, C# 3.0 Pocket Reference, and LINQ Pocket Reference as well as LINQPad, has very nice Threading in C# article (well, it is 77 pages long and available in PDF format as well). As the author says, “[it] tackles difficult issues such as thread safety, when to use Abort, Wait Handles vs Wait and Pulse, the implications of Apartment Threading in Windows Forms, using Thread Pooling, Synchronization Contexts, Memory Barriers and non-blocking synchronization constructs.”

“Bit Twiddling”

Needed to do some “weird” things recently that involved bit operations, e.g. to create masks with certain number of bits set. During my “research” I found few interesting places:

Appropriate Use of Type Inference or (2 var | ! 2 var)

Type inference is a new C# feature allowing one to declare variable in a type safe way, while “saving typing”. As it is a new feature, there are still going debates (sometimes heated) about appropriate uses of type inference. When to use Type Inference on jaredpar’s WebLog represents the “use it whenever it’s possible” camp, while Appropriate use of Local Variable Type Inference on B# .NET Blog (really nice blog indeed!) represents the “use it only when it’s absolutely clear what the type is” camp. My view coincides with that expressed in the latter article, i.e. “use it only when it’s absolutely clear what the type is”. Especially, one starts to value this approach in case one has to read the code written by someone else: it is sometimes (usually?) difficult to grasp what that code is doing, and then on top of that one has to figure out what are the actual types of variables. Brrrrrrr…

Today’s Links

These are mostly related to systems’ programming:

Today’s Sites/Blogs

Today’s Sites/Blogs


PostSharp is a free and open source aspect-oriented programming (AOP)/policy injection framework that can reduce the number of lines of code and improve its logical decoupling by allowing encapsulation of e.g. transaction management, logging, caching, or security aspects as custom attributes. Own custom attributes can be developed that will add new behaviors to code.