Building C# Applications: Unit - 2
Building C# Applications: Unit - 2
Building C# Applications: Unit - 2
UNIT 2
Building C# Applications
RNSIT Bengaluru
les.
Configuring the C# Command-Line Compiler
Configuring Additional .NET Command-Line Tools
RNSIT Bengaluru
RNSIT Bengaluru
Cont..
4
Once you have updated the Path variable, you may take a test
RNSIT Bengaluru
gacutil /?
RNSIT Bengaluru
RNSIT Bengaluru
Purpose
used to specify the name of the assembly to be
created.
By default, the assembly name is the same as
the name of the *.cs le(case of an *.dll) or the
name of the type containing the programs
Main() method (case an *.exe).
builds an executable console application.
/target:exe
This is the default le output type, and thus
may be omitted when building this application
type.
/target:library builds a single-le *.dll assembly.
builds a module. Modules are elements of
/target:module
multile assemblies
/target:winexe
free to build Windows-based applications
By Prof. Suma M G, Dept. of MCA
RNSIT Bengaluru
7
Cont..
8
RNSIT Bengaluru
Then it appears:
By Prof. Suma M G, Dept. of MCA
RNSIT Bengaluru
using System;
using System;
using System.Windows.Forms;
class TestApp{
public static void Main(){
Console.WriteLine("Testing! 1, 2,3");
class HelloMessage {
public void Speak(){
MessageBox.Show("Hello...");
h.Speak();
}
}
By Prof. Suma M G, Dept. of MCA
RNSIT Bengaluru
Cont
11
You can compile your C# files by listing each input file explicitly:
csc /r:System.Windows.Forms.dll Testapp.cs Hellomessage.cs
RNSIT Bengaluru
RNSIT Bengaluru
RNSIT Bengaluru
Cont..
14
RNSIT Bengaluru
Cont..
15
RNSIT Bengaluru
/bugreport flag will allows you to specify the file that will
generate that have various statistics of current build including
any errors encountered during the compilation time.
Example: using System;
class BugDemo {
public static void Main() {
Console.WriteLine("Test! 1 2 3")
//Compilation time error
}
}
Then, compile the program as
csc /bugreport:bugdemo.txt BugDemo.cs
By Prof. Suma M G, Dept. of MCA
RNSIT Bengaluru
Or
cordbg /?
Flags
Meaning
b[reak] set or display current break points
del[ete] Removes one or more break points
ex[i]
Exit the debugger
By Prof. Suma M G, Dept. of MCA
RNSIT Bengaluru
Cont.
18
Flags
g[o]
o[ut]
si
so
p[rint]
Meaning
Continue the process of debugging until the next
breakpoint
Step out of the current function
Step into the next line
Step over the next line
Print all loaded variables.
RNSIT Bengaluru
Cont
19
RNSIT Bengaluru
Pre-Processor Directives
20
line.
Preprocessing directives start with #.
Whitespace is allowed before and after the #.
The # is followed by an identier that is the directive name.
Syntax:
# directive name or # Identifier
Directive Name
Meaning
#if
#else, #elif,
#endif
RNSIT Bengaluru
Cont..
21
Directive Names
Meaning
#dene
#undef
#warning
#error
#line
#region
#endregion
RNSIT Bengaluru
Example
22
ExPreD.cs
Output:
RNSIT Bengaluru
RNSIT Bengaluru
Output
24
RNSIT Bengaluru
Questions
25
1.
2.
3.
4.
5.
RNSIT Bengaluru