B
Brett Kelly
Hello,
I'm trying to dynamically create instances of objects using
Activator.CreateInstance(), but I'm getting the above error.
Here's the code that calls CreateInstance:
-------------------------------
Type t = em.GetTypeByExt(ext);
object[] targs = new object[]
{me.Filename,me.TargetDirectory,me.ExecArgs};
BaseFile f = (BaseFile)System.Activator.CreateInstance(t,targs);
-------------------------------
Now, the Type t is correct (verified it with the visual studio
debugger), and targs are the constructor arguments.
Here's the constructor for BaseFile (an abstract class):
-------------------------------
public BaseFile(string fname, string tdir, string execargs)
{
this.Filename = fname;
this.TargetDirectory = tdir;
this.ExecArgs = execargs;
}
-------------------------------
I'm not sure what I'm doing wrong here, anybody have any suggestions?
Thanks!
Brett
I'm trying to dynamically create instances of objects using
Activator.CreateInstance(), but I'm getting the above error.
Here's the code that calls CreateInstance:
-------------------------------
Type t = em.GetTypeByExt(ext);
object[] targs = new object[]
{me.Filename,me.TargetDirectory,me.ExecArgs};
BaseFile f = (BaseFile)System.Activator.CreateInstance(t,targs);
-------------------------------
Now, the Type t is correct (verified it with the visual studio
debugger), and targs are the constructor arguments.
Here's the constructor for BaseFile (an abstract class):
-------------------------------
public BaseFile(string fname, string tdir, string execargs)
{
this.Filename = fname;
this.TargetDirectory = tdir;
this.ExecArgs = execargs;
}
-------------------------------
I'm not sure what I'm doing wrong here, anybody have any suggestions?
Thanks!
Brett