Compile simple C# example in Web Matrix

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to compile a simple c# class in Web Matrix called howdy.cs:


// Program start class
public class HowdyPartner
{
// Main begins program execution
public static void Main()
{
// Write to console
System.Console.WriteLine("Howdy, Partner!");
}
}

However, it appears the 'Start' option is not available. What can I do to
simply compile this class?

I have heard there is a compiler in the SDK but I would have thought that
would have been downloaded with WebMatrix or the .NET framework which is
installed on my windowx xp machine.

Appreciate some guidance to get my first pathetic C# class up and running :)

Many thanks
Jason
 
I've never used web matrix but as I understand it, it is an
asp.net development IDE, not made for compiling console
apps. Correct me if I'm wrong.

Take this modified version of your code:

//BEGIN CODE----------------------------

using System; //added System namespace!

namespace TestClass //added custom namespace!
{
// Program start class
public class HowdyPartner
{
// Main begins program execution
public static void Main(string[] args) //added args!
{
// Write to console
System.Console.WriteLine("Howdy, Partner!");
}
}
}

//END CODE------------------------------

Paste it into notepad and save it as "HowdyPartner.cs"
(without quotes - and make sure extention is ".cs" not ".txt")

Compile it from the command-line using the C# compiler (csc).

http://www.publicjoe.f9.co.uk/csharp/cs04b2.html

You must have the .net SDK installed, get it here if you
don't already have it:

http://www.microsoft.com/downloads/...a6-3647-4070-9f41-a333c6b9181d&displaylang=en

And off you go!

-v
 
Awesome! I did as intructed and downloaded the SDK and read through the sdk
including the 'tools' section.

However, I still don't see any refeence to the C# compiler...where is this
tool?

Many thanks
Jason

I've never used web matrix but as I understand it, it is an
asp.net development IDE, not made for compiling console
apps. Correct me if I'm wrong.

Take this modified version of your code:

//BEGIN CODE----------------------------

using System; //added System namespace!

namespace TestClass //added custom namespace!
{
// Program start class
public class HowdyPartner
{
// Main begins program execution
public static void Main(string[] args) //added args!
{
// Write to console
System.Console.WriteLine("Howdy, Partner!");
}
}
}

//END CODE------------------------------

Paste it into notepad and save it as "HowdyPartner.cs"
(without quotes - and make sure extention is ".cs" not ".txt")

Compile it from the command-line using the C# compiler (csc).

http://www.publicjoe.f9.co.uk/csharp/cs04b2.html

You must have the .net SDK installed, get it here if you
don't already have it:

http://www.microsoft.com/downloads/...a6-3647-4070-9f41-a333c6b9181d&displaylang=en

And off you go!

-v
 
Ok, I figured it out.

To compile the simple howdy, cs one would do the following:

1. Run | Command Prompt
2. CD\ to your DIR containing file
3. Use following statement:

csc /t:library howdcy.cs

However, I was getting the following error (Please see:
http://www.communitymx.com/kbase.cfm?cid=1033)

csc' is not recognized as an internal or external command, operable program
or batch file.
or
'vbc' is not a recognized as an internal or external command, operable
program or batch file.

To work around this issue, you must place the path of the command line tools
into the Path system variable. To do so:
1.. Open the System Properties dialog from the Control Panel, or by right
clicking on My Computer and choosing Properties, or by pressing [windows
key] + [Pause/Break]
2.. Click on the Advanced tab, and click the Environment Variables
3.. Highlight the System Variable Path and click edit
4.. Append the paths to the command line tools to the existing value

By default, those paths are:
c:\program files\microsoft visual studio
..NET\FrameworkSDK\BIN;c:\windows\microsoft.net\framework\v1.1.4322 - if you
installed the SDK with Visual Studio, if you installed only the framework,
the path would likely be:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322

If you'd like more information on using the command line compiler, see the
article:
Demystifying .NET Compilers
http://www.communitymx.com/abstract.cfm?cid=A9938E090C326799



Awesome! I did as intructed and downloaded the SDK and read through the sdk
including the 'tools' section.

However, I still don't see any refeence to the C# compiler...where is this
tool?

Many thanks
Jason

I've never used web matrix but as I understand it, it is an
asp.net development IDE, not made for compiling console
apps. Correct me if I'm wrong.

Take this modified version of your code:

//BEGIN CODE----------------------------

using System; //added System namespace!

namespace TestClass //added custom namespace!
{
// Program start class
public class HowdyPartner
{
// Main begins program execution
public static void Main(string[] args) //added args!
{
// Write to console
System.Console.WriteLine("Howdy, Partner!");
}
}
}

//END CODE------------------------------

Paste it into notepad and save it as "HowdyPartner.cs"
(without quotes - and make sure extention is ".cs" not ".txt")

Compile it from the command-line using the C# compiler (csc).

http://www.publicjoe.f9.co.uk/csharp/cs04b2.html

You must have the .net SDK installed, get it here if you
don't already have it:

http://www.microsoft.com/downloads/...a6-3647-4070-9f41-a333c6b9181d&displaylang=en

And off you go!

-v
-----Original Message-----
I am trying to compile a simple c# class in Web Matrix called howdy.cs:


// Program start class
public class HowdyPartner
{
// Main begins program execution
public static void Main()
{
// Write to console
System.Console.WriteLine("Howdy, Partner!");
}
}

However, it appears the 'Start' option is not available. What can I do to
simply compile this class?

I have heard there is a compiler in the SDK but I would have thought that
would have been downloaded with WebMatrix or the .NET framework which is
installed on my windowx xp machine.

Appreciate some guidance to get my first pathetic C# class up and running :)

Many thanks
Jason


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top