【问题标题】:Third party dll added in visual studio: are you missing a using directive or an assembly reference在 Visual Studio 中添加的第三方 dll:您是否缺少 using 指令或程序集引用
【发布时间】:2021-07-02 14:39:02
【问题描述】:

我使用 Visual Studio 创建了一次 Tester.dll 文件,现在我想将其用于新的 Visual Studio 项目。在解决方案资源管理器中,我单击了项目并添加了dll,然后我可以在程序集下看到它。然后在Program.cs 文件中我写了using Tester;。

如果我构建它,我会收到错误消息The type or namespace Tester could not be found (are you missing a using directive or an assembly reference)

还有没有我错过的步骤?

我的项目结构如下:

Server
│ └── Communication.sln
|── Lib
│ ├── Tester.dll
├── CommunicationServer
│ ├── bin
│ ├── obj
│ ├── CommunicationServer.csproj
│ └── Program.cs
│ ├── Tester.dll
├── Communication
│ ├── bin
│ ├── obj
│ ├── Communication.csproj

很遗憾,我既不了解 Visual Studio,也不了解 C#。

【问题讨论】:

  • 您需要在 CommunicationServer 中添加对 Tester.dll 的引用(在 Dependencies 下) - 您不应该直接将 dll 添加到项目中。
  • 如果我引用Tester.dll(在它真正产生的文件夹中)它仍然找不到它。

标签: c# visual-studio dll


【解决方案1】:

在 Visual Studio 中打开您的项目,然后转到解决方案资源管理器窗口。在那里您将看到一个部分作为参考,右键单击参考,从菜单中选择添加参考选项。将出现一个窗口,底部有一个浏览选项,现在找到Tester.dll,构建应用程序。您的代码现在应该可以成功编译了。

注意:您尝试从 Tester.dll 访问的类应使用公共访问修饰符进行标记。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-08
    • 1970-01-01
    • 2022-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多