This is my first time posting anything here. I have learned c# before when in school. But now at work I'm trying to make a program using c# and I'm encountering a program. I am a novice, and is hoping everyone's expertise can help me.

Essentially I'm developing a program using Visual c# 2008 that will read in values from an Excel spreadsheet and do some calculations with it and return a value. Fairly simple program.

So, I have write the code in Visual C# 2008, and using it I could compile the code into an executable. This part is fine.

But now I want to compile this using the Visual Studio 2008 command prompt. The reason I want to this is because I want make this program into a dll library as part of the requirement. So for simplicity's sake I just tried to compile it as an executable in cmd as well.

So I had: csc TestFunction.cs

But to my surprise i got the error: "cs0234: The type or namespace name "Office" does not exist in the namespace "Microsoft" (are you missing an assembly reference?)"

I don't understand how I got the error as I have added references Microsoft Office 12 Object Library & Microsoft Excel 12 Object Library and I added the following to my code:

using Microsoft;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;

When I build the solution in Visual C# it generates a working exe.
So why is this happening in cmd?

Any help would greatly appreciated. Thank you.


9 Years
Discussion Span
Last Post by __avd

You don't have to compile the project from the command line to generate a .dll file. In Visual Studio, select the Class Library project type, and that will compile into a .dll file. After you select the correct project type, you can use the command line tool called msbuild to build the project.


Command-Line requires Reference of .dll.

>csc YourProg.cs /t:library /r:System.Data.OracleClient.DLL /r:.....
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.