简体   繁体   English

没有可用的.exe,是否引用了另一个项目的C#代码?

[英]Reference C# code from another project without the .exe available?

I have a solution with two projects: 我有两个项目的解决方案:

  • Project A, a large private project 项目A,一个大型私人项目
  • Project B, a small public project which needs a subset of the functions from A 项目B,这是一个小型公共项目,需要A的部分功能

I'm just getting started on Project B, but I already have a Project (A) which handles many things that will be needed in the new one. 我刚刚开始进行项目B,但是我已经有一个项目(A),它可以处理新项目中需要的许多事情。 I would obviously like to reuse these functions without copying them. 我显然想重用这些功能而不复制它们。

If I add these as a reference in Visual Studio (2012) everything works code wise for Project B, but the generated assembly directory will also contain a functioning copy of Project A.exe. 如果我将这些作为参考添加到Visual Studio(2012)中,那么对于Project B,所有代码都可以正常工作,但是生成的程序集目录还将包含Project A.exe的有效副本。

I need to include my code from Project A without having a compiled .exe file in my output directory. 我需要包含Project A中的代码,而在输出目录中没有已编译的.exe文件。 Either by having it as a .dll file or inlined into the main assembly without having to refactor out the relevant parts of Project A into a new class library project. 通过将其作为.dll文件或内联到主程序集中,而不必将Project A的相关部分重构为新的类库项目。 Is this possible? 这可能吗?

Thanks for your time 谢谢你的时间

I think you can try to change the Application Type of your "A Project" from Windows Application to Class Library 我认为您可以尝试将“ A项目”的Application TypeWindows Application更改为Class Library

After that, compile your "A Project" and you will find the .dll in the output directory (instead the .exe ) 之后,编译您的“ A Project”,您将在输出目录中找到.dll (而不是.exe )。

Now that you have the .dll you can use it as a reference in your "B Project". 现在,您有了.dll您可以将其用作“ B项目”中的引用。

To change the Application Type you can visit this link form MSDN 要更改Application Type您可以访问此链接表格MSDN

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

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