I’m trying to use System.Activator.CreatInstance to Create an object based on the typeName. I’m using the following code:
Object DataInstance = System.Activator.CreateInstance(
System.Reflection.Assembly.GetExecutingAssembly().FullName,
"CMS.DataAccess.SQLWebSite");
IWebSite NewWebPage = (IWebSite)DataInstance;
SQLWebSite implements IWebSite. But, I get the following error: “Unable to cast object of type ‘System.Runtime.Remoting.ObjectHandle’ to type ‘CMS.DataAccess.IWebSite’.” Any ideas where I am going wrong?
Try
unwrapafter you call theCreateInstance, i.e.: