Search code examples
c#.netbuildcompiler-errorscsc

I am unable to build a dll file using the command line without main method


My goal is to build a dll from the command line since I do not have visual studio installed.

So far, I have created a class file named AuthenticatedProxy.cs and went to the command line and ran the following command:

C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe C:\AuthenticatedProxy.cs

The output is an error saying: 'AuthenticatedProxy.exe' does not contain a static 'Main' method suitable for an entry point. (Note that my class file does not have a main method)

How do I compile a class file into a dll? Do I have the correct command?


Solution

  • Using command line is a good practice for every developer.

    You may use -target flag:

    C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe -target:library C:\AuthenticatedProxy.cs