【发布时间】:2018-07-14 10:51:54
【问题描述】:
所以我有两个 dll,Algorithms.dll 和 Data_Structures.dll(这些是我在 GitHub 上找到的项目中制作的)。使用浏览功能,我设法将两个 DLL 文件添加为对我的 Visual Studio 2017 控制台项目的引用。问题是我不能对他们做任何其他事情。每当我尝试在任一文件中引用某些内容时,都无法找到它。唯一可以识别的是名称空间,但其中没有任何内容。
我需要做什么才能让 VS 找到这些 DLL 包含的类以便我可以使用它们?我知道我需要使用 Algorithms.Sorting 作为示例,但我不能调用 anything,所以我以这个为例。
附:如果您需要更多信息,请询问。我不确定与这个问题有什么关系。
编辑:好的,有这样的例子是误导性的。已更正,但请阅读问题。
编辑:我在 Monodevelop 上试过这个并得到同样的问题。也许不是 IDE 的问题?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Algorithms.Sorting; // Error, Sorting cannot be found, and neither can the file container Sorting
using Data_Structures; //Perfectly ok, can find the namespace
namespace CS_HW2_Testing_App
{
class Program
{
static void Main(string[] args)
{
// I'd like to call MergeSort and so forth here. What am I missing?!
}
}
}
如果有帮助,这是包含 MergeSort 的文件的顶部部分
using System;
using System.Collections.Generic;
using Algorithms.Common;
namespace Algorithms.Sorting
{
public static class MergeSorter
{
//
// Public merge-sort API
public static List<T> MergeSort<T>(this List<T> collection, Comparer<T> comparer = null)
{
comparer = comparer ?? Comparer<T>.Default;
return InternalMergeSort(collection, 0, collection.Count - 1, comparer);
}
...
【问题讨论】:
-
最好的猜测是您引用的是在添加
MergeSorter类之前编译的Algorithms.dll的旧版本。尝试删除并添加您知道 使用该类编译的Algorithms.dll的引用。此外,请确保Algorithms项目确实编译并且没有出现任何编译错误。 -
我无法引用任何内容。我今晚才编译它,只有一个编译。有一些警告,但它们来自我不会使用的项目。感谢您的建议!
-
查看项目的引用时,对dll的引用是否有效?没有警告标志?
-
是的,与正常参考的唯一可检测差异是“强名称”为 False。
标签: c# .net visual-studio dll