简体   繁体   English

在同一解决方案中的不同测试项目中引用项目中的 C# 命名空间

[英]Refer a C# namespace in a Project from a different Testing-Project within the same solution

I'm setting up a bot project with Visual Studio in C#.我正在 C# 中使用 Visual Studio 设置一个机器人项目。 Now I want to create a Testing-Project for automated Testing.现在我想为自动化测试创建一个测试项目。 Therefore I have created a new "MSTest Test Project (.Net Core)" within the same Solution.因此,我在同一个解决方案中创建了一个新的“MSTest 测试项目(.Net Core)”。

Here is the project file for the first Project.这是第一个项目的项目文件。

Here is the project file for the Testing Project这是测试项目的项目文件

Here you can see that I'm trying to refer to another namespace called "KJCBOT.Bots".在这里,您可以看到我试图引用另一个名为“KJCBOT.Bots”的命名空间。 This Namespace is defined in the real project inside the "Dispatchbot.cs" file.这个命名空间是在“Dispatchbot.cs”文件内的真实项目中定义的。 But somehow this isn't working for me.但不知何故,这对我不起作用。 But why?但为什么?

How to add reference different projects in same solution如何在同一解决方案中添加引用不同的项目

The thing you are trying to accomplish is to add a reference to Project1 from Project2.您要完成的事情是从 Project2 添加对 Project1 的引用。 Right-click the project, choose "Add References" then from the "Projects" tab, choose Project1.右键单击项目,选择“添加引用”,然后从“项目”选项卡中选择 Project1。

For more clarity or detail explanation and examples please follow the link.如需更清晰或详细的解释和示例,请点击链接。

How to add reference in Visual Studio / How Reference works in VS 如何在 Visual Studio 中添加参考/参考如何在 VS 中工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从同一解决方案打开 c# 命名空间,在 f# 中引用项目 - open c# namespace from same solution, referenced project in f# DllImport 从 c# 项目到相同解决方案中的 c++ 项目 - DllImport from c# project to c++ project in same solution 从同一解决方案MVC中的不同项目访问EF ConnectionString - Accessing EF ConnectionString from different project within same solution MVC C#无法从同一解决方案中的另一个项目捕获异常 - C# Cannot catch exceptions from another project within same solution 在同一解决方案中的WPF项目中调用多个报表时,C#报表错误 - C# report error when calling multiple reports from within WPF project in the same solution 从相同解决方案C#的另一个项目访问资源文件 - Accessing Resource files from another project of same solution C# Visual Studio - Intellisense 无法识别同一解决方案中另一个项目中的命名空间 - Visual Studio - Intellisense not recognizing namespace in another project within same solution c#从同一解决方案中的其他项目运行表格 - c# run form from other project in same solution 从同一解决方案C#中的另一个项目中读取配置属性 - Read config properties from another project in the same solution C# 在同一解决方案中在C#项目和C ++项目之间进行交互 - interacting between a C# project and C++ project in same solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM