制作 C# 项目 DLL 和 EXE
我正在开发一个项目,需要有一个可执行文件以便用户可以运行配置界面和一个可以嵌入其他项目以使用其他一些功能的 DLL。有没有办法让 Visual Studio 同时生成可执行文件和 DLL(而不是每次都手动切换)?
I'm working on a project where I need to have both an executable so that the user can run a configuration interface and a DLL that can be embedded in other projects to use some of the other features. Is there a way to make Visual Studio produce both an executable and a DLL (as opposed to switching it manually every time)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我同意 TJMonk15 的观点,但我认为应该明确解释这一点。您应该有两个项目,一个是 DLL 项目,另一个是普通项目。 DLL 项目应该包含所有可重用代码。正常的项目应该是您正在构建的应用程序,它将引用您的可重用 DLL。这样您就可以在 DLL 项目中构建一个可用于您将来的任何项目的框架。
一个很好的例子就是当你制作游戏时。您的游戏引擎将是 DLL,您正在制作的游戏将是可执行项目。可执行项目将包含所有不可重用的特征,例如游戏 GUI 和内容。
I agree with TJMonk15, but i think this should be explained explicitly. You should have two projects, one project that is a DLL, and one that is a normal project. The DLL project should have all your re-usable code. The normal project should be the application you are building, which will reference your re-usable DLL. This way you can build a framework in the DLL project that can be used for any of your future projects.
A good example of this is when you are making a game. Your game engine would be the DLL, and the game you are making would be the executable project. The executable project will contain all the non-reusable traits such as game GUIs and content.
为什么不将大部分代码放在一个项目中(带有类型库的输出),然后编写一个引用 DLL 的可执行文件?
Why wouldn't you put most of the code in one project (With an ouput of type Library) and then write an executable that referenes the DLL?