Convert a completed project to a DLL

61,885

Solution 1

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

Solution 2

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.

Share:
61,885

Related videos on Youtube

Danny Beckett
Author by

Danny Beckett

I'm a PHP/JS developer & C#/XAML programmer from Liverpool . I lived in Amsterdam for a couple of years, and Oslo for a little while too. OS windows-server centos GUI c# .net wpf visual-studio Web php html5 css3 javascript jquery SQL mysql mssql t-sql oracle pl-sql sybase-asa sqlanywhere HTTPd apache iis

Updated on December 05, 2020

Comments

  • Danny Beckett
    Danny Beckett over 3 years

    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.

    • leppie
      leppie almost 12 years
      Change the option in Properties on the project...
  • Admin
    Admin almost 12 years
    Ok thanks JohnnBlade it works and I created dll now. But second question is I imported that dll into other project and I wanted to run this dll in Form Load.İs this posssible ?
  • Admin
    Admin almost 12 years
    Ok thanks Killercam it works and I created dll now. But second question is I imported that dll into other project and I wanted to run this dll in Form Load.İs this posssible ?
  • JohnnBlade
    JohnnBlade almost 12 years
    You should normally create a new question for this, if you want to add your DLL to a new project just add it as a reference, and add the using on top of your code class/form and from there you can use your classes/forms/enums in your code
  • Admin
    Admin almost 12 years
    Ok understood you.I did what you said.When I debug my Project I want to see dll like an exe run. Am I clear?sorry if I am not clear
  • MoonKnight
    MoonKnight almost 12 years
    Yes. Just include a reference to your DLL in the 'Solution Explorer on the right hand side of Visual Studio. Right click references and add the DLL. Doing this you can call your form as you would if it were part of the actual solution. One thing to be wery of though is the namespace of the form in the referenced DLL, if this is not the same as the containing project you will have to be sure to include the namespace...
  • Admin
    Admin almost 12 years
    Ok understood you.I did what you said.When I debug my Project I want to see dll like an exe run. Am I clear?sorry if I am not clear.
  • JohnnBlade
    JohnnBlade almost 12 years
    If you added your .dll to the new project and you build that new project, you will se that .dll next to your .exe in your bin/debug or bin/release folder
  • Admin
    Admin almost 12 years
    sorry for asking again but I did what you said exactly. First; I obtained dll and added in other project then it runned with no error... Second ; I obtained dll again(but this time dll is related with database) and added in other project then I am getting this error FileNotFoundException .\n 'Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' file or a collection or one of its dependencies. The system can not find the file specified.
  • Admin
    Admin almost 12 years
    sorry for asking again but I did what you said exactly. First; I obtained dll and added in other project then it runned with no error... Second ; I obtained dll again(but this time dll is related with database) and added in other project then I am getting this error FileNotFoundException .\n 'Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' file or a collection or one of its dependencies. The system can not find the file specified.
  • MoonKnight
    MoonKnight almost 12 years
    You will have to ask another question in the forum for this problem. Post another question and be specific on the details, linking to this question if required. Also, to avoid down votes, spell check and be clear on what you want to achieve...
  • Ramesh S
    Ramesh S almost 10 years
    Hi @Killercam,I have same problem.I have create website Project in VSExpress2013Web.Can please help me.How to create DLL file my enter website project.
  • MoonKnight
    MoonKnight almost 10 years
    What are you having trouble with?
  • Ramesh S
    Ramesh S almost 10 years
    I have created website Project and one class library project.I have reference is c-sharpcorner.com/uploadfile/syedshakeer/… How to test the dll file working or not.Please let me know.I am doing correct way or not I don't know.
  • MoonKnight
    MoonKnight almost 10 years
    Why do you need a separate .dll? If they are both managed (written in C#) then include a reference to the .dll in your web-project and attempt to call a method from the .dll that writes to the output window via System.Console.WriteLine("DLL is working"); - that will tell you.