Convert a completed project to a DLL

2019-01-25 03:33发布

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

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.

标签: c# winforms dll
3条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-25 04:04

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 type to class library, you can find that in your project properties under the tab application

Output type

查看更多
【Aperson】
3楼-- · 2019-01-25 04:06

If you want to hide the fact that the file is an application you can actually just rename .exe to .dll and the program will still work perfectly ;)

In regards to the OP's original question, you could just add the project to any other solution you use and then build against it? There is no requirement for it to be a class library if the projects are in the same solution.

(If anyone knows of issues caused by doing this PLEASE let me know. I have production code running this way!)

查看更多
何必那么认真
4楼-- · 2019-01-25 04:16

If you are using VS2010, go to your solution in 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'

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

I hope this helps.

查看更多
登录 后发表回答