compiling C# with command-line

Centinall

Member
Jul 5, 2003
59
0
0
I'm just starting to learn C#. I was raised on Java. Have some questions.

I know how to compile C# files, ie:
~csc file.cs
to create an .exe , which requires an entry point (main).

But what if i just want to compile a class (is it called a class in C#?) that has no entry point? I don't want to just
include the class in the file that will be compiled into the exe. I've figured out how to create a .dll. If a dll is like a
class in C#, does this mean that I have to register the dll? In java you compile the .java file into a .class file
whether it has an entry point or not.

I've googled and didn't really get any good information on this. I'm sure this is very easy in VS.Net, but I'm using
the command-line tools.

Sorry if this is a stupid post, but I really didn't know where to look for this info.

BTW, has anyone tried out winCV.exe that comes with the SDK. If you haven't, check it out... it's a damn good
tool.

Thanks a lot guys.
 

Kinesis

Senior member
May 5, 2001
475
0
76
I am not sure about the answer to your question. But thanks for the tip about the winCV.exe file. Cool Tool!

I would say this, that .NET does not compile to a class file, like Java anyhow. Either EXE, DLL, or similar extension. But saying that, I do believe that I read some where about an intermediate file type... which C#, C++, and VB.NET all compile too. I could be on crack too!

A tool I use "ildasm.exe" (Intermediate Language Disassembler) to look at the intermediate language code.

 

Centinall

Member
Jul 5, 2003
59
0
0
thanks for the reply. Yeah, i've read up on MSIL, CLR, just-in-time comp, etc... however, i can't seem to find the answer to my question. i'm sure i wouldn't have this problem if i just used vs.net like everyone else. however, i don't want to buy vs.net, and want to learn the command-line way anyway.

so perhaps i should give a more detailed example.
Let's say i want to create a double-linked list in C# (guys, let's not get into why one would do that in .net and not just use array lists, etc...).
there will be 3 files:

- node.cs //a node object
- linkedList.cs //linkedList object
- test.cs //program with an entry point that instantiates the linkedList which will in turn instantiate the node class.

the test.cs will be compiled into an.exe file(right?). what will the other two be compiled into? dll's? btw, i have used namespaces.

thanks.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
it's been a while since i used the commandline compiler for c#, so i don't know the answer off the top of my head on if it is possible to compile your code files into some kind of .o file. what i do know is that in your example, you could compile all three together into a single exe, even if there are multiple namespaces within.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
i turned on my other computer. you just do this:

csc /t:module test.cs /out:test.mod

it creates a module file, which you can link in with the /addmodule commandline parameter. without the /out parameter, it seems to want to supply a .netmodule extension to the file, but i'm pretty sure the expected extension is .mod.