Problem using System.Xml in unit test in MonoDevelop (MonoTouch)

When I have a unit test that requires the System.Xml or System.Xml.Linq namespaces, I get the following error when I run the test:

System.IO.FileNotFoundException : Could not load file or assembly 'System.Xml.Linq, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

Things I've verified:

  • I have the proper usings in the test.
  • The project builds with no problems.
  • Using these namespaces work fine when I run the app in the emulator.
  • I've written a very simple unit test to prove that unit testing works at all (and it does).

I'm a test driven kinda guy so I can't wait to get this working so I can progress with my app.

Thanks in advance.


You need to add the same dll's (assemblies) that monotouch uses in the references of your unit test project.

These are found in /Developer/MonoTouch/usr/lib/mono//...

For example, i needed to use System.Xml, and so i edited the references of my test project and added the following assembly:


There is one for system.xml.linq as well, and these are the proper versions you need (

Probably Mono isn't finding the needed library in the places it looks. NUnit by default tries to copy your test library to some other place and so it won't find libraries that aren't globally visible (those system libraries installed in the GAC). Not sure if you can set in Monodevelop the option for NUnit not to copy the library under test to avoid the problem. One possibility is to run the standalone NUnit Console runner where you set the options or give NUnit more information to make it copy more things, but that is complicated by having to make NUnit use the right profile (Monotouch's which is based on Silverlight)

Need Your Help

What happens if a C++ shared lib throws an exeption in a C project

c++ c exception shared-libraries

I'm writing a shared library with a C API, but most code is written in C++.

CCGLView Blank in UINavigationController

iphone ios cocos2d-iphone

I have a CCGLView which is created in Interface Builder. I have a root Navigation Controler onto which I'm pushing a custom UIViewController. When this UIViewController loads, I wire up my CCGLView...