简体   繁体   English

共享项目-不编译

[英]Shared project - not compiling

Recently I learned about shared projects and how I can separate large chunks of my code (ie: all my UI controls) into another area to clean my up main code without adding a dll to my execution path. 最近,我了解了共享项目,以及如何将大段代码(即我的所有UI控件)分离到另一个区域,以清理主代码,而无需在执行路径中添加dll。 AMAZING, except it only partially works. 令人惊奇的是,它仅部分起作用。

If I move code from my main project into the shared and change the namespace (to the shared one), things still work. 如果我将代码从主项目移到共享中并更改名称空间(更改为共享名称空间),则一切仍然有效。 But when I create a new file directly in the shared project, ONLY that file is able to see itself. 但是,当我直接在共享项目中创建新文件时,只有该文件才能看到它自己。

It's only after closing VS multiple times, re-compiling, removing the shared project, sacrificing a chicken then maybe class is finally seen. 只有在多次关闭VS,重新编译,删除共享项目,牺牲一只鸡之后,​​才可能最终看到类。 MAJOR waste of time with not lessons learned. 浪费大量时间,没有经验教训。

What is the fast route to getting my new file seen while still using shared projects? 在仍然使用共享项目的情况下显示新文件的快速途径是什么?

== Steps to reproduce ==复制步骤

  1. Create a new project (WinForms, in this case) 创建一个新项目(在本例中为WinForms)

  2. Create a shared project in the main project + add reference in main project 在主项目中创建一个共享项目+在主项目中添加引用

    • Note, the shared project is in a sub-folder of the parent project, to keep things organized 请注意,共享项目位于父项目的子文件夹中,以保持事物的井井有条
  3. Create a class in shared project and try to use it in the min project 在共享项目中创建一个类,然后尝试在最小项目中使用它

Screenshot 屏幕截图

It works for me (VS2017), when I add the shared project next to the main project in the same solution and add reference to the shared project as well as the proper using directives in the main project. 当我在同一解决方案中将共享项目添加到主项目旁边,并在主项目中添加对共享项目的引用以及正确的using指令时,它对我有用(VS2017)。

However I came across the limitation that it will not let you share WinForms stuff. 但是我遇到了一个限制,那就是它不会让您共享WinForms的东西。 Maybe that is what you're up against. 也许这就是您要面对的。 This seems to be by design 这似乎是设计使然

I think the class library and other project have different target framework. 我认为类库和其他项目具有不同的目标框架。 Why dont you try to just set them to a particular.Net Framework. 为什么不尝试仅将它们设置为特定的.Net Framework。

It should really solve the problem. 它应该真正解决问题。

Check this 检查一下

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM