I am using a generic Stack type in monotouch (namespace System.Collections.Generic). In a separate nunit project, that is referencing only the assemblies from the monotouch package, I am开发者_JS百科 extending my monotouch class and reinstantiating the stack:
using System.Collections.Generic;
namespace Tests
{
public class MyExtendedClass : MyExtendableClass
{
public MyExtendedClass ()
{
m_myStackVariable = new Stack<string> ();
which gives me the following error message:
Cannot implicitly convert type
System.Collections.Generic.Stack<string>
toSystem.Collections.Generic.Stack<string>
When I try "go to base" on the Stack type it shows me mscorlib in the assembly browser which under it´s System.Collections.Generic namespace doesn´t hold the Stack<> type like the System.dll does in the assembly browser.
Anyone have any idea what´s going on here? Are there two types in the same namespace with the same name that differ between these projects? What´s giving me grief here?
Make sure your NUnit project is referencing the MonoTouch core libraries. Still, sometimes even that doesn't fix the issue depending on your code specifically.
The NUnit project will use the libraries for Mono on the Mac, so the MonoTouch libraries returning a Stack(T), for example, can't be cast to a Stack(T) on the Mac.
This issue has basically made unit testing impossible for me, luckily using the "var" keyword can get around it, but it depends on your situation.
Can you post more code? There may be a workaround.
精彩评论