Use csc.exe to compile assembly referencing COM DLL
<p>How could I compile a .cs program that references a COM DLL from the command line?</p>

<p>Assume I have COM DLL with the following path: C:\Projects\com1.dll
Assume C# code is in file: C:\Projects\program.cs</p>

<p>I've tried this
csc.exe /lib:"C:\Projects" /reference:com1.dll "C:\Projects\program.cs"</p>

<p>hoping to get program.exe  This fails so the references for COM dlls by this method is wrong route.</p>

<p>-- Adding specifics in reference to first answer --
Okay assuming in this case I'm using ADO</p>

<pre><code>tlbimp "C:\Program Files\Common Files\Syste \ado\msador15.dll"
</code></pre>

<p>Get this response</p>

<pre><code>Type library imported to ADOR.dll
</code></pre>

<p>Now placing that new DLL created by tlbimp into the same directory as a program that has using ADODB in it:</p>

<pre><code>csc /lib:. /reference:ADOR.dll Program.cs
</code></pre>

<p>Returns</p>

<pre><code>Program.cs(2,7): error CS0246: 
The type or namespace name 'ADODB' could not be found 
(are you missing a using directive or an assembly reference?)
</code></pre>

<p>-- Overloads Issue --</p>

<pre><code>using System;
using ADODB;

class Program
{
    static void Main(string[] args)
    {
        Connection connection = new Connection();
        connection.Open(args[0]);
        //connection.Open(args[0], "", "", -1);
        Console.WriteLine(connection.State);
        connection.Close();
    }
}
</code></pre>
