C# 将完成的项目转换为 DLL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11536140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 18:11:11  来源:igfitidea点击:

Convert a completed project to a DLL

c#winformsdll

提问by

How can I convert a completed C# project to a DLL, in order to use it in other projects?

如何将完成的 C# 项目转换为 DLL,以便在其他项目中使用它?

I have Googled but lots of results say to open the Class Library, write your code there, then Build Solution and everything will be ok.

我用谷歌搜索过,但很多结果都说要打开类库,在那里编写代码,然后构建解决方案,一切都会好起来的。

But my question is: how can I convert a completed project to a DLL? The project can include lots of Forms etc.

但我的问题是:如何将完成的项目转换为 DLL?该项目可以包括许多表单等。

采纳答案by JohnnBlade

if your code is complete, you need to create a Class project out of it, if you already have a project then only transfer the useful code to the class project for reuse in other projects

如果你的代码是完整的,你需要用它创建一个类项目,如果你已经有一个项目,那么只将有用的代码转移到类项目中以便在其他项目中重用

or change the Output Typeto class library, you can find that in your project properties under the tab application

或者改成Output Type类库,你可以在你的项目属性中的tab应用下找到

Output type

输出类型

回答by MoonKnight

If you are using VS2010, go to your solution in Visual Studio,

如果您使用的是 VS2010,请转到 Visual Studio 中的解决方案,

  1. Click the 'Project' tab
  2. Select 'Project Properties' down at the bottom of the menu
  3. Now in the 'Properties' window click 'Application'. This should show you a menu
  4. On this menu, select the 'Output type' as 'Class Library'
  1. 单击“项目”选项卡
  2. 选择菜单底部的“项目属性”
  3. 现在在“属性”窗口中单击“应用程序”。这应该会显示一个菜单
  4. 在此菜单上,选择“输出类型”作为“类库”

Now when you compile the project you will get your output as a DLL (.dll) in the relevant bin folder.

现在,当您编译项目时,您将在相关 bin 文件夹中以 DLL (.dll) 形式获得输出。

I hope this helps.

我希望这有帮助。