如何在VS c#控制台应用程序中使用引用的c#dll代码

如何在VS c#控制台应用程序中使用引用的c#dll代码,c#,.net,visual-studio,dll,C#,.net,Visual Studio,Dll,所以我有两个dll,Algorithms.dll和Data\u Structures.dll(我从GitHub上找到的项目中创建了它们)。使用浏览功能,我成功地将这两个DLL文件添加为对Visual Studio 2017控制台项目的引用。问题是我不能对他们做任何其他事情。每当我试图引用任何一个文件中的内容时,都无法找到它。唯一可以识别的是名称空间,但名称空间中没有任何内容 我需要做什么才能让VS找到这些DLL包含的类,以便我可以使用它们?我知道我需要使用算法。排序作为示例,但我不能调用任何东西

所以我有两个dll,
Algorithms.dll
Data\u Structures.dll
(我从GitHub上找到的项目中创建了它们)。使用浏览功能,我成功地将这两个DLL文件添加为对Visual Studio 2017控制台项目的引用。问题是我不能对他们做任何其他事情。每当我试图引用任何一个文件中的内容时,都无法找到它。唯一可以识别的是名称空间,但名称空间中没有任何内容

我需要做什么才能让VS找到这些DLL包含的类,以便我可以使用它们?我知道我需要使用
算法。排序
作为示例,但我不能调用任何东西,因此我将此作为示例

另外,如果您需要更多信息,请询问。我不确定什么与这个问题有关

编辑:好吧,有这样的例子是有误导性的。已更正,但请阅读问题

编辑:我在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);
        }
...
使用系统;
使用System.Collections.Generic;
使用算法。常见;
名称空间算法.排序
{
公共静态类合并分类器
{
//
//公共合并排序API
公共静态列表合并排序(此列表集合,Comparer=null)
{
比较器=比较器??比较器。默认值;
返回InternalMergeSort(集合,0,集合.计数-1,比较器);
}
...

在第一个代码块中,您导入了错误的命名空间:
使用算法。MergeSort
应该是
使用算法。Sorting
。然后您可以在代码中使用
MergeSorter.MergeSorter(…)

您需要引用命名空间而不是类

using Algorithms.Sorting; //instead of using Algorithms.MergeSort;

另外,确保类是公共的

即使在VS中突出显示了错误,也要尝试构建该项目。如果它编译,则需要重新启动VS和/或清除R#缓存。最好的猜测是,您引用的是在添加
合并分类器
类之前编译的
算法.dll
的旧版本。尝试删除并添加你知道的
Algorithms.dll
的引用是用该类编译的。另外,确保
Algorithms
项目确实编译了,并且没有抛出任何编译错误。我什么都不能引用。我只是今晚编译了它,只有一次编译。有一些警告,但是y来自我不会使用的项。感谢您的建议!当您查看项目的引用时,对dll的引用是有效的?没有警告标志?是的,与正常引用唯一可检测到的区别是“强名称”为假。