The Case of the Unit Test and the Native DLL

August 28, 2010

I got an email from a former client a couple of days ago with roughly the following problem description: I’m trying to run a unit test (with MSTest) which calls an interop function. The native DLL (written in C) is located in C:\Windows\System32. For some reason, when running the test Visual Studio can’t seem to find the DLL, and throws a FileNotFoundException. Moreover, I can’t even see the DLL in the File—>Open dialog in Visual Studio! I tried launching Visual Studio as admin and as standard user but the result was the same. What am I missing...
no comments

Demonstrating CLR Side-by-Side Execution

August 27, 2010

Starting from CLR 4.0, multiple versions of the CLR can be loaded into the same process. This doesn’t mean that you can mix the 1.1 and 2.0 runtimes, but you can have CLR 2.0 loaded in the same process with CLR 4.0. This is great news for managed shell extension developers, managed COM object developers, and other library developers whose libraries are consumed by unmanaged code. The CLR Inside Out: In-Process Side-by-Side column contains all the nitty-gritty details. One fact you should be aware of is that if you load a managed library that targets CLR 2.0 from...
no comments

PSSCor2: GC Heap Analysis Commands

August 26, 2010

In our previous trip to PSSCor2-land, we’ve seen some object inspection commands tailored for ADO.NET and ASP.NET applications. This time, let’s take a step back and use some commands that display and analyze the managed heap. The fundamental !DumpHeap command receives a minor facelift in PSSCor2—it has some new parameters. One welcome addition is the –gen parameter, which filters the output by a certain GC generation. Another great idea is the –random switch that prints every 1000th object so that your screen doesn’t get flooded with instances and so that you can inspect a random sampling. Finally, there’s...
no comments

Inspecting Local Root Lifetime

August 25, 2010

The .NET GC determines which objects are reachable by constructing a graph of references, starting from a set of roots. One type of roots is local references that are stored on thread stacks. The GC relies on the JIT to supply it with information about the local variables in each active method, and uses that information to determine whether a root should be traversed. When all optimizations are enabled, the JIT and GC cooperate so that local roots are relevant only as long as the local variable is still going to be used. This is a source of...
no comments

Great News: WCF MOC and XNA Windows Phone 7 Labs

August 24, 2010

This is just a quick post to let you know about two important accomplishments we at Sela had in the past few days. In a few days, the WCF 4.0 MOC 10263A (Microsoft Official Course) is going to be released to training centers all over the world. This course was developed by Sela from scratch, and I’ve been a fly on the wall during its production process. (Well, to tell you the truth, I did quite a bit of technical editing work on this project, which has certainly earned me some hate from the content...
no comments

PSSCor2: Object Inspection Commands, Part 2

In the previous installment, we’ve seen how PSSCor2 makes it easy to display the contents of a DateTime, of an IPAddress, of an XmlDocument, and of certain collection classes. Now we’ll take a look at some additional commands that inspect heap objects. The !DumpField commands automates the process of displaying a particular object field (by field name). This is especially useful when combined with some looping constructs like .foreach to execute a script in the debugger session. In the following example, I have an Employee class that has an _id field, and I want to display all the...
no comments

PSSCor2: Object Inspection Commands, Part 1

August 23, 2010

PSSCor2 is a recently released debugging extension used internally by Microsoft support engineers to debug managed applications. It’s a separate download that installs its 32-bit and 64-bit flavors, and currently there’s only a version that works with CLR 2.0, but its additions on top of the core SOS are significant and therefore it’s worth learning how to use them. In this installment, we’ll take a look at some of the new object inspection commands. Stay tuned for more—all in all, there are a couple of dozen new commands that I’d like to show you. Let’s start with...
no comments

MSDN Event: Parallelism in Visual Studio 2010 – Redux

August 22, 2010

Almost a year ago, I delivered an MSDN Event on Parallel Programming in Visual Studio 2010. At the time, I used the Visual Studio 2010 Beta 1 but the demos worked fairly well. Today, I delivered another version of the same talk, with only minor modifications. The difference is just that Visual Studio 2010 is out, and we’re talking about a mature framework which you should be using in your concurrent applications today. You can download the demos (which haven’t changed :-)) and slides from here. I mentioned several resources during the session which...
no comments

The Case of the Rogue Heartbeat Timer

August 19, 2010

A few days ago I had to debug a curious out-of-memory condition and encountered a pattern that you may find useful. The application in question consists of a set of WCF services that communicate with each other strictly through WCF channels. Occasionally, especially under heavy load, database operations start timing out, memory usage goes through the roof, and an OOM is thrown. Instead of telling you in so many words what I did with the memory dumps, I wrote a simple repro which I’m going to work with. First of all, let’s run the application and simulate the...
no comments

Detecting the STA Thread from GetToSTA

August 15, 2010

When a thread makes a method call through an appropriately marshaled COM proxy that points to a thread in a different STA (Single-Threaded Apartment), ole32.dll kicks in and implements the minute details of marshaling input parameters across the required boundary, waiting for the call to return, and unmarshaling the return value and output parameters. In a debugger, a thread making a COM call to another STA will have a native call stack similar to the following: 0:002> kb ChildEBP RetAddr  Args to Child               ... ntdll!ZwWaitForSingleObject+0x15 ... KERNELBASE!WaitForSingleObjectEx+0x98 ...
tags: ,
one comment