我有一些C#代码,它在mono和Microsoft的.net编译器下编译都很好,但是只能在mono上运行。
错误信息如下(换行由我添加):
Unhandled Exception: System.TypeLoadException:
Could not load type 'Hasse.Groups.Heavy.Product.PowerGroup`1'
from assembly 'Hasse, Version=1.0.x.y, Culture=neutral, PublicKeyToken=null'
because it has recursive generic definition.
该类型实际上具有递归泛型定义,因此我的问题是:为什么它能在mono中工作?[代码运行并产生了预期结果]
完整的源代码在这里:https://github.com/miniBill/Hasse
仍会崩溃的简化代码在此处:
public class Group<T> : IWrappableGroup<WrapperGroup<T>> {}
public class WrapperElement<T> {}
public interface IWrappableGroup<U> {}
public class WrapperGroup<T> : Group<WrapperElement<T>> {}
class MainClass {
public static void Main(string[] args){
var ng = new Group<object>();
}
}
这里有一个证明它在mono上能工作的链接:http://ideone.com/ZvA3I