I’m experiencing a very strange issue:
I use the NUnit framework for testing in WP7 project. Currently im trying to use a Silverlight Unit Test Framework to run tests on device (using NUnitTestProvider).
Everything works fine except for tests which use System.Action. In these tests I get a runtime error :
Could not load type ‘System.Action’ from assembly ‘mscorlib,
Version=3.7.0.0
For example this doesn’t work (non-generic System.Action)
public void MethodThatAcceptsRawAction(System.Action callback);
...
MethodThatAcceptsRawAction( () => Console.WriteLine("Hi"));
But this will work
public void MethodThatAcceptsOneArgAction(System.Action<object> exCallback);
...
MethodThatAcceptsOneArgAction( (ex) => Console.WriteLine(ex.ToString()));
I checked public types in mscorlib.dll that was in memory, it has no System.Action, but has System.Action'1 type. Looks like System.Core.dll has System.Action.
Microsoft decided to split System.Action variations between two libraries but runtime binder doesn’t know where to look for the type.
Maybe someone had the same problem or at least knows something to look at?
Thanks in advance
Okay, looks like the solution was found.
Default WP7 project template defines mscorlib reference. This is a bit weird, i thought that it is always referred by compiler (if used without /nostdlib key).
I removed this reference and everything is is okay now.
P.S. I dont mark this post as answer, probably someone can explain this behavior. This would be a real answer.