[Mono-list] Using mcs in a C# program

Daniel Morgan danmorg@sc.rr.com
Sat, 7 Dec 2002 11:11:49 -0500


Here is a test program that tries to load mcs as an object to run mcs and
compile a program.  It compiles successfully, but it fails running.  It
fails because it cannot find the mcs.exe
assembly.  I copied mcs.exe to mcs.dll, and re-ran McsTest.exe on Mono -- it
worked this time.

// TestHello.cs
using System;

namespace HelloTest
{
	class TestHello
	{
		public static void Main(string[] args)
		{
			string[] mcsArgs = new string[] {
						       "TestHello.cs"
						      };
			Mono.CSharp.Driver.Main(mcsArgs);
		}
	}
}

DanielMorgan@DANPC ~/mono/20021130/mcs/mcs
$ mcs TestMcs.cs -r mcs.exe
Compilation succeeded

-- with only mcs.exe

DanielMorgan@DANPC ~/mono/20021130/mcs/mcs
$ mono TestMcs.exe

** (TestMcs.exe:3252): WARNING **: Could not find assembly mcs
Can not open image TestMcs.exe

DanielMorgan@DANPC ~/mono/20021130/mcs/mcs
$ cp mcs.exe mcs.dll

DanielMorgan@DANPC ~/mono/20021130/mcs/mcs
$ cp mcs.exe mcs.dll

DanielMorgan@DANPC ~/mono/20021130/mcs/mcs
$ mono TestMcs.exe
Compilation succeeded

-----Original Message-----
From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com]On
Behalf Of Guenther Roith
Sent: Saturday, December 07, 2002 9:43 AM
To: Daniel Morgan; Mono-List
Subject: Re: [Mono-list] Using mcs in a C# program


Hi!

There is a class for doing this:

Microsoft.CSharp.Compiler.Compile()

look at msdn or in the Microsofct Documentation for details.

I'm not sure if this has been implemented in mono, but it much better, than
invoking mcs or csc directly.
If not, it's worth implementing. I guess it's also used by ASP.NET.


_______________________________________________
Mono-list maillist  -  Mono-list@ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list