M
melwinphilip
Hi,
I'm new to C# and I'm wondering what I'm doing wrong here....
I've created a library (using csc/t:library) with the following
source...
*******************
using System;
interface ITest {
void M1();
}
class Class1:ITest{
public void M1() {
Console.WriteLine("In M1()");
}
}
*******************
Now I create a client with the following source
*******************
using System;
using System.Reflection;
interface ITest {
void M1();
}
class DynamicInvoke
{
public static void Main(String [] args)
{
String path = "Class1";
Assembly a = Assembly.Load(path);
Type mm = a.GetType("Class1");
ITest it = (ITest)Activator.CreateInstance(mm); <-- Exception
it.M1();
}
}
*******************
I get a the following exception
"Unhandled Exception: System.InvalidCastException: Specified cast is
not valid.
at DynamicInvoke.Main(String[] args)"
Plz help...
Regds,
Melwin.
I'm new to C# and I'm wondering what I'm doing wrong here....
I've created a library (using csc/t:library) with the following
source...
*******************
using System;
interface ITest {
void M1();
}
class Class1:ITest{
public void M1() {
Console.WriteLine("In M1()");
}
}
*******************
Now I create a client with the following source
*******************
using System;
using System.Reflection;
interface ITest {
void M1();
}
class DynamicInvoke
{
public static void Main(String [] args)
{
String path = "Class1";
Assembly a = Assembly.Load(path);
Type mm = a.GetType("Class1");
ITest it = (ITest)Activator.CreateInstance(mm); <-- Exception
it.M1();
}
}
*******************
I get a the following exception
"Unhandled Exception: System.InvalidCastException: Specified cast is
not valid.
at DynamicInvoke.Main(String[] args)"
Plz help...
Regds,
Melwin.