A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Compiling from the Command PromptThis tutorial shows you how you can compile a simple piece of code from the C# command prompt compiler and how to add references. |
On Friday, July 23rd 2004 at 04:52 AM By Andrew Pociu (View Profile) ![]() ![]() ![]() ![]() (Rated 4 with 26 votes) |
|||||
|
This tutorial will show you how to compile C# code from the DOS command prompt. It doesn't analyze all the parameters you can pass to the compiler and any other compiling methods, it only shows you how to compile a simple piece of code. First we have to create a C# file that we shall compile:
Paste this into Notepad and save it at C:\toCompile\Form1.cs. Now from the Start Menu in the Microsoft Visual Studio .NET\Visual Studio .NET Tools program group, open Visual Studio .NET 2003 Command Prompt: ![]() The command prompt compiler starts:
We change to the toCompile directory using the command CD C:\toCompile at the command prompt:
Now let's try to compile the program using the csc command. But first, we should not forget that we need to add some references like we usually do in Visual Studio. Type csc /? in the command prompt to list the help associated with this command. You can see that using /reference we can add references for the compilation of the code:
Now that we know how to add a reference we can compile.
That's it. You can now open the compiled application by typing Form1 because the file Form1.exe is in the toCompile folder. When you run the application you'll see that a console window and an empty form will pop-up. |
||||||
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
||||||
|
||||||
Current Commentsneed betterhelp then this
There is no need to add the references!!!! Simply compiling with csc does it all
I couldnt figure out how to save the notepad document to( C:toCompileForm1.cs.) .I couldnt find the visual studio tools either in the start menu so this was totally useless for me..I really want to learn this stuff so I am really frustrated .
Please give me a detailed tutorial on how to compile programmes using c++ object oriented language.Thank you.
Since I am new to C#, this tutorial helped me a lot, thanks! But is there a way to compile the program using the DOS command prompt (not the Visual Studio .Net command prompt)? I tried using it, but the "csc" command is not recognized.
Yes, you need to download the <a href="http://msdn.microsoft.com/netframework/downloads/framework1_1/" target="_blank">.NET Framework 1.1 SDK</a> first if you don't have it installed. Then you can compile from the command prompt just like you did with Visual Studio.
Hi, is there a way to see what "Compile command" visual studio generates when you launch the build command from the IDE?
Thanks
When i refer an assembly using /r i got an error saying metadata can not be found. But the assembly which I referred is registered in GAC. But the problem is solved when i specify full path of the assembly in /r option. Can someone tell me why CSC is not able to locate the assembly available in GAC?
Thanks!
But is there a way to compile the program using the DOS command prompt (not the Visual Studio .Net command prompt)? I tried using it, but the "csc" command is not recognized.
-Karthick
d
Hi
Is there a way to create a reference to assembly from Dos Command prompt for C# project(.cproj) instead of .cs file using "csc" or any other command.
Thanks in Advance
-Srivani
thanks a lot...it helped a lot
You don't need to use the visual studio command prompt, you can compile the program from any command prompt. You just need to include csc.exe in your path environmental variable and you can run it from any directory.
As for .csproj files, the C# compiler won't recognize them, they are a VS manifestation. If you want to compile a project that has multiple source files like class1.cs, class2.cs, and mainapp.cs (entry point), you would do:
csc.exe class1.cs class2.cs mainapp.cs
and it will output mainapp.exe
thanks.....
Good tutorial.
I have a class called MyClass.cs that has a statement to get data from web.config like below
var = System.Configuration.ConfigurationManager.AppSettings["KeyName"].ToString()
I compiled MyClass.cs successfully using C:\toCompile>csc /r:System.Configuration.dll MyClass.cs
I am getting runtime error "Object reference not set to an instance of an object".
Please help me how do you include the web.config and get data from it.
Thanks
Ram
I keep getting a message saying that my class "is not recognized as an internal or external command, operable program, or batch file."
My gut tells me there is a problem with my environment variables. Any ideas?
Thanks.
Hi,
I am not able to compile .cs file with visual studio 2008 command prompt. I am getting a error message that the system cannot find the path specified. I try to change the directry using CD command but it's not working.I am using windows vista. Can you please let me know why i am getting such error? Please help.
Thanks this helped me.
how to include csc.exe in the path environment variable
If you want to compile from clipboard with csc see
http://reboltutorial.com/blog/redirect-shell-to-rebol-console/
Anybody have any idea how to convert a complex large VS.NET solution and/or project (VS.NET 2003, 2005, or 2008) into a command line build script such that you can build it from the command line, and ideally without need of having VS.NET installed, like just having the .NET framework is enough?
That would really be useful.
please tel me how to compile the c# program using command prompt /step wise
Related Tutorials
Related Source Code
C# Job Search