Microsoft.Practices.Composite.Presentation could not be loaded error

Jul 30, 2010 at 2:31 PM


First off I am glad to finally see an Silverlight Unit test plugin for Resharper. Really been missing that.

And now to my problem; I'm sure I'm doing something dumb, but I can't get my unit tests to run.

When I run them I get an error saying "Microsoft.Practices.Composite.Presentation" or one of it dependencies could not be loaded.

I'm using:

  • Visual Studio 2010 Ultimate - 10.0.30319.1
  • Resharper (C# Edition) - 5.1.1727.12
  • Silverlight Toolkit Apil 2010, also tried November 2009.
  • AgUnit for R# 5.1 -

I've referenced the assemblies mentioned in the FAQ, I also tried adding a reference to Microsoft.Practices.Composite.Presentation.
I also checked that none of the plugin files are blocked.
And I am of cause targeting Silverlight 4.

I hope you can help me, the plugin looks really good

Aug 1, 2010 at 9:22 PM
Edited Aug 1, 2010 at 9:25 PM

Hi Jacob

I'm guessing the "Microsoft.Practices.Composite.Presentation" is a dependency of your project that you are testing. It may be an indirect dependency (dependency of a dependency). Try adding all the references that your normal application project has, to your test project. I'm guessing it's a dependency of  "Microsoft.Practices.Composite.Presentation" that can't be found.

You can try to enable breaking on handled exceptions (Debug > Exceptions > Check the checkbox for CLR exceptions) then try "Silverlight debug unit tests", it might give you better information.

If you can't find the problem, try to reproduce it in a simple project, send it to me and I'll have a look.


Aug 2, 2010 at 2:06 PM

Hehe, I knew it was something dumb. I just need to add a reference to "Microsoft.Practices.Composite".

Anyway thanks for the help, the plugin is great.

I have run in to another problem, though. Properly not directly related to AgUnit, but seems that any webrequests made by a System.Net.WebClient instance during a unit test, is not actually "requested". Meaning that the webservice is never called. I tried using Fiddler (Web Debugging Proxy), and the call to the webservice is never made. I tried stepping through the code, and everything seems fine, the methods on the WebClient instance is called, but the events for completion is never raised. No errors either. But if the code is run from browser hosted silverlight (from visual studio), everything is working fine.

Maybe it's a known issue?

Aug 2, 2010 at 3:37 PM
Edited Aug 2, 2010 at 3:42 PM

Hi Jacob

Can you post a sample test. I'm particularly interested in how you "block" the test until the request is received.

It may be something that we are forgetting, maybe one of the asynchronous testing attributes ?


AgUnit also has a fix where it doesn't wait for the silverlight UI thread (aka the Dispatcher thread) during the test run. The default silverlight test runner from the toolkit doesn't do this.

If you wait for a dispatch run between your tests, you can only run 1 test during each frame of your silverlight application. 

Say if your test application has 30 FPS, it means that only 30 tests run each second at maximum. I usually work with a project that has about 3000 unit tests, making the theoretical absolute minimum duration of the test run 100 sec. With this fix the actual test run usually takes less than 50 sec.

This basically means that you can't do UI testing with AgUnit, or anything else that relies on the dispatcher thread (Web requests, UI controls, ...).


I already had the idea in mind to introduce UI testing to AgUnit, by making this a configuration setting and introducing a UI surface, like the test runner from the toolkit does. So it may be available in a future release.

Aug 2, 2010 at 4:27 PM


I was not aware that web request where connected to the dispatcher thread, so that might be it (I am using a WebClient instance).

I wrote a simple helper class some time time ago for testing asynchronous functions. Basicly it runs a while loop that tests a Func<bool> delegate at intervals, seperated by Thread.Sleep(). It will then return when the delegate returns true or a timeout is reached.

Basicly the test can be boiled down to:

public void DoWebReqeust()
	var client = new WebClient();

	var completed = false;

	var timeout = DateTime.Now.AddSeconds(10);

	client.DownloadStringCompleted += (sender, args) => completed = true;

	client.DownloadStringAsync(new Uri(""));

	while (!completed)
		if (timeout.CompareTo(DateTime.Now) < 0)
			throw new Exception("Timeout");

Aug 2, 2010 at 5:26 PM

If this code works with the regular unit test runner, then I'm probably wrong on requests being tied to the Dispatcher thread.

How are you starting the regular unit test runner, from a http:// or file:// url ?

AgUnit is using file:// urls (so no web server involved), and that might be the problem.


Aug 2, 2010 at 6:04 PM

I am not using the regular unit test runner. I meant that when I run the actual project, the requests works just fine.