Archive for the ‘Tools’ Category

Specifying Custom NUnit Runner in MonoDevelop

2015/11/18

I just discovered that the NUnit Add-In in MonoDevelop has a nice although undocumented feature: you can specify a custom test runner in the .csproj file, either as an executable or as a type. If you have the NUnit.Runners nuget package installed in your solution/project and you want MonoDevelop to run the unit tests with nunit-console.exe instead of the built-in runner, you can add the following to your .csproj file:

   </PropertyGroup>
     <TestRunnerCommand>packages/NUnit.Runners.Net4.2.6.4/tools/nunit-console.exe</TestRunnerCommand>
   </PropertyGroup>

Now when you run your unit tests in MonoDevelop they will be run by nunit-console. This is useful when your unit tests make use of features that the NUnit Add-in doesn’t support yet, like ActionAttributes.

The other tags that are supported are:

  • TestRunnerArgs: Allows to specify additional command line arguments to the TestRunnerCommand
  • TestRunnerType and TestRunnerAssembly: allow to specify a test runner class/type and the assembly where to find this type.

If both TestRunnerArgs and TestRunnerType are specified, TestRunnerArgs takes precedence.

Tracking undisposed objects

2014/10/29

Every so often I come across a crash or a hang in my project or unit test that is caused by missing dispose calls. This is especially true if a managed object holds references to COM objects and even more so if it’s not thread-safe. Since garbage collection runs on a different thread the finalizer gets called on that thread as well, often causing trouble.

Often it’s not obvious which object doesn’t get disposed and causes this behaviour. Usually it takes me several days to find the culprit and fix the bug. Over the years I developed some strategies that get refined over time. When I came across this situation again last week I decided to create a tracker class that keeps track of the created and disposed objects together with a counter that identifies the creation call. This made it easier to add a method call to the constructor and the Dispose() method but it still required quite a bit of repetitive work to temporarily add those calls to the c’tor and Dispose methods.

On the weekend I stumbled upon the nuget package Fody; this helped an idea to materialize that I had for a few days. As a consequence I created a fody addin, Undisposed.Fody, that injects calls to my tracker class into the constructor and dispose methods of all types in the current assembly. The fody addin gets run during the build of the current project. I also created a standalone application that allows to hack an existing assembly.

The modified assembly outputs a line on the console if an object gets created and when it gets disposed, and it dumps all undisposed objects. Hopefully this will give some hints which object creation calls to inspect.

The source code is available on github, and there is also a nuget package.

Remote Debugging with MonoDevelop

2013/12/04

This morning I tried to debug some Mono code in a Ubuntu 13.10 Saucy virtual machine that doesn’t have all the developer tools installed. Miguel de Icaza recently blogged about remote debugging, but it took a bit of fiddling to get it working. Here are my findings:

In the VM start your application with

mono --debug --debugger-agent="address=192.177.88.11:10000,transport=dt_socket,server=y" \
    /full/path/to/mono-application.exe

The IP address is the address of the VM, transport is a required argument, dt_socket seems to be the only allowed option. It is important to specify the full path to your managed application otherwise you’ll get an error that the application can’t be found.

Then on your developer machine set the environment variable MONODEVELOP_SDB_TEST and start MonoDevelop:

export MONODEVELOP_SDB_TEST=1
monodevelop-4.0

This adds a new menu item that allows to start a remote debugging session, under Run -> Run With -> Custom Command Mono Soft Debugger. This opens a dialog window; enter the IP address of your VM (192.177.88.11) and the port (10000) and start the session with the Connect button. This starts the application in the VM. Debugging works the same as if you would start the app locally. Great!

Lost Menu in Monodevelop in Unity

2011/06/07

Recently I got a new desktop computer on which I installed Ubuntu 11.04 Natty with the Unity UI. Yesterday I compiled Monodevelop 2.6 beta 3 (using the scripts described here) which worked fine – only when I run monodevelop the menu can’t be found anywhere: there is no menu in the monodevelop window nor in the global menu bar. Since it’s pretty hard to do any work without a visible menu, I decided to try to get this fixed. (more…)

Debug.Assert and Mono

2009/05/06

On Microsoft’s .NET implementation on Windows a Debug.Fail() (which is equal to a Debug.Assert(false)) when run on a debug build displays a dialog box with the options Abort, Retry, Ignore. When run in the debugger it also displays the call stack.

On Mono however no dialog box shows; it behaves the same as when the user pressed ‘Ignore’. What’s worse is that it doesn’t display the call stack by default, even when run in debugger. This doesn’t give any hint if an exception happened. (more…)

Building MonoDevelop from SVN

2009/01/15

Yesterday I managed to build MonoDevelop from SVN source. I had done it before but had forgotten how to do it, and there are no fool-proof instructions on what you need to build. (more…)

Distorted Video when Using RecordMyDesktop

2008/11/10

Today I was looking for a screen recording application on Linux. I came across recordmydesktop (and it’s GUI gtk-recordmydesktop) which looked very promising. It is included in the Ubuntu repositories and it is easy to use: just select the window you want to capture and click on the record button. However, when I looked at the generated video the characters in the recorded window looked unacceptably distorted. (more…)

Fix broken user status in Pidgin/Meanwhile

2008/09/05

The user status display of the meanwhile plugin in Pidgin on Ubuntu is broken. If a user has logged in to the Sametime server before I start Pidgin, the user will still show offline in Pidgin. This has the effect that you get messages from offline users 🙂 . (more…)

Fetchmail with SSL on OpenWRT

2008/09/02

Last night I tried to get fetchmail to work on a router running OpenWRT (Kamikaze). Turns out that the fetchmail package is compiled without SSL support so it is impossible to get mails through a secure connection. (more…)

How to Find the Data Directory of SQL Server 2005 in a Script

2008/08/29

In versions of SQL Server prior to 2005 finding the directory where SQL Server creates its databases was pretty easy since there was a registry key named after the instance of SQL Server and a value that specified the path.

With SQL Server 2005 Microsoft changed everything, making it a challenge to retrieve the correct data directory from a build script. The solution we had in our build script turned out to be wrong, so this afternoon I discovered the correct way to do it. (more…)