Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 泛型接口库:无法从程序集加载类型_C#_Generics_Interface_Mono - Fatal编程技术网

C# 泛型接口库:无法从程序集加载类型

C# 泛型接口库:无法从程序集加载类型,c#,generics,interface,mono,C#,Generics,Interface,Mono,出于实验目的,我试图构建一个二元搜索树库,从中可以实例化BST来保存唯一节点或冗余节点(冗余节点是树中一个值与另一个值相等的节点)。为了可重用性,我定义了一个通用接口ITree和两个子接口IUnique和IRedundant 作为我回复的原因,库代码可演示如下[文件名:itest.cs]: 但是,将这两种方法汇编在一起完全符合预期: $ mcs -out:itest.exe main.cs itest.cs $ mono itest.exe MyNS.Tree`1[System.Int32]

出于实验目的,我试图构建一个二元搜索树库,从中可以实例化BST来保存唯一节点或冗余节点(冗余节点是树中一个值与另一个值相等的节点)。为了可重用性,我定义了一个通用接口ITree和两个子接口IUnique和IRedundant

作为我回复的原因,库代码可演示如下[文件名:itest.cs]:

但是,将这两种方法汇编在一起完全符合预期:

$ mcs -out:itest.exe main.cs itest.cs
$ mono itest.exe
MyNS.Tree`1[System.Int32]
为了保持模块化,我如何将库与应用程序逻辑分开


编辑(2010年1月11日):是的,这是Mono 2.8.x的一个bug,在2.10版中已经修复。

我不熟悉Mono编译器,所以我无法告诉您正确的语法,但我认为更简单的答案是,您的第二个库没有正确引用itest库。它们正确地编译在一起就是代码正确性的证据


我认为你已经完成了99%的步骤……只需仔细检查你的引用语法。

在.NET上运行良好,我会提交一个mono错误。@Hans Passant,完成。这可能是编译器的一个bug吗?我想这是一个bug——请看我在原始帖子下面对@Hans Passant的回复。谢谢
public class ITest {
    public static void Main() {
        System.Console.WriteLine(typeof(MyNS.Tree<int>));
    }
}
$ mcs -out:itest.dll -t:library itest.cs
$ mcs -out:itest.exe main.cs -reference:itest
error CS0011: Could not load type 'MyNS.ITree`3[T,N,MyNS.IUnique`2[T,N]]' from assembly 'itest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Compilation failed: 1 error(s), 0 warnings
$ mcs -out:itest.exe main.cs itest.cs
$ mono itest.exe
MyNS.Tree`1[System.Int32]