Convert a completed project to a DLL

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.

Answers


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


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.


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!)


Need Your Help

How do I pass arguments to a Java instrumentation agent?

java arguments instrumentation javaagents

How do I pass arguments to a java.lang.instrument instrumentation agent? The documentation simply states:

How do I get the keyWindow reference in a swift app?

ios swift

In Objective-C in the viewDidLoad method of a UIViewController I do this to get the keyWindow reference in my iOS app: