Activator.CreateInstance question
I have been trying to simulate the functionality I have had in the past using
Server.CreateObejct(progid,servername)
in vbscript on a classic ASP page. It appears I need to be using the System.Activator class, but I have had problems with type casting. For example:
Type myType = Type.GetTypeFromProgID(progid,servername);
Lib.Object myObject = (Lib.Object)Activator.CreateInstance(myType);
When I execute this code, I receive an invalid cast. If I use the following:
Type myType = Type.GetTypeFromProgID(progid,servername);
Object myObject = Activator.CreateInstance(myType);
I don't receive any invalids, but the functions from the object are not available (i.e.; myObject.DoSomething). I have tried several variations including:
Type myType = Type.GetTypeFromProgID(progid,servername);
Object myObject = Activator.CreateInstance(myType);
Lib.Object myObject2 = (Lib.Object)Marshal.CreateWrapperOfType(myObject,typeof(myObject));
One last bit of info, I have an asp page on the same server with the Server.CreateObject call and it works fine.
Thanks for any help,
ctcoley