Converting .exe project to class library

15,657

Solution 1

Project > Properties > Application tab, change Output type to "Class Library".

For the record, this isn't actually necessary. An EXE project works fine as an assembly reference. Assuming classes were declared public, something you might have to fix anyway to make them work in a library.

Solution 2

In .NET, an .exe and a .dll are both legal as references. This is because in .NET, there exists two type of assemblies:

  1. process assemblies - known in public as executables, or exe
  2. library assemblies - known in public as dll

An assembly in .NET holds many modules, that in turn holds one or more classes (the guideline is one class per module). These modules is turned into IL code at compile time and JIT'd at runtime. The important part for both types of assemblies is that each assembly holds meta data like

  1. modules
  2. methods
  3. types

there exists in an assembly. And because of that the runtime, and compiler, can easily determine how to fx call a certain method in a process assembly.

I think, without being an expert on the subject, that the major difference between process assemblies and library assemblies is that process assemblies holds some extra code, telling the runtime how to load, and what to load.

Solution 3

Go into My Project in your solution, select the Application tab, and change the Application type to Class Library.

Share:
15,657
SuperTron
Author by

SuperTron

Updated on June 06, 2022

Comments

  • SuperTron
    SuperTron almost 2 years

    I have a semi-large C# .exe project in visual studio 2010 Ultimate, and I would like to convert it to a DLL class library. Is there an easy way to do this that doesn't involve creating a new class library project? Thanks beforehand.