如何在同一解决方案中添加对另一个项目的引用?

发布于 2024-10-07 11:15:25 字数 171 浏览 0 评论 0原文

我的解决方案中有两个项目。第一个项目是网站(实际上是Web服务),其他项目是控制台应用程序。

是否可以将第二个项目中的引用添加到第一个项目中?在网站项目下,我有一些代码我想在控制台应用程序中使用它。

我可以将网站的引用添加到第二个控制台项目,但我不需要也不想要这个。第二个项目仅用于一些测试目的。

I have two projects in my solution. First project is web site (actually web service) and other project is console app.

Is it possible to add reference in second project to the first one ? Under web site project I have some code I'd like to use it in console app.

I can add reference from web site to the second console project but I don't need nor want this. This second project is just for some testing purposes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泅渡 2024-10-14 11:15:25

您应该创建第三个项目,类型为类库。然后你让其他两个项目都引用它。

正如 MSDN 页面上所述关于可用的项目模板:使用类库模板快速创建可与其他项目共享的可重用类和组件。

You should create a third project, of the type Class Library. And then you make both the other projects reference that.

As it says on this MSDN page about the available project templates: Use the Class Library template to quickly create reusable classes and components that can be shared with other projects.

夜吻♂芭芘 2024-10-14 11:15:25

遇到了同样的场景。您需要打开 Visual Studio 的 2 个实例,以管理员身份在两个实例中加载解决方案,在第一个实例中调试 Web 服务,然后将第二个实例中的服务引用添加到控制台项目中。

Ran into the same scenario. You need to open 2 instances of Visual Studio, load up your solution in both as administrator, debug your web service in the 1st instance, then add the service reference in the 2nd instance to your console project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文