[Mono-devel-list] Problem with VS.NET compiled assemblies

Eto eto at shaw.ca
Mon Mar 22 23:29:59 EST 2004


I'm trying to run the following (source below) using mint on gentoo-ppc with 
the latest CVS (as of March 22nd).  If i compile with VS.NET 2003, it gives 
the following error when running using mono in linux:

Unhandled Exception: System.InvalidCastException: Cannot cast from source type 
to destination type.
#0: 0x0000d castclass  in ConsoleApplication2.Class2::add_Changed 
([O:0x1005ede0] )
#2: 0x00016 calli      in ConsoleApplication2.Class2::add_Changed 
([O:0x100b9fc8] )
#3: 0x00023 callvirt   in ConsoleApplication2.Class1::.ctor ()
#4: 0x00000 newobj     in ConsoleApplication2.Class1::Main ([O:0x10055a30] )

If I compile using mono, then it runs fine in linux and windows..

Any ideas?

Cheers,
Curtis.

----- Source Code -----
using System;
namespace ConsoleApplication2
{
	public class Class2
	{
		public Class2()
		{
		}
		public event EventHandler Changed;
	}
	public class Class1
	{
		private Class2 class2;
		public Class1()
		{
			class2 = new Class2();
			class2.Changed += new EventHandler(class2_Changed);
		}
		[STAThread]
		static void Main(string[] args)
		{
			Class1 class1 = new Class1();
		}
		private void class2_Changed(object sender, EventArgs e)
		{
			Console.WriteLine("yoe, i've changed");
		}
	}
}



More information about the Mono-devel-list mailing list