Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to cast System.Runtime.Remoting.ObjectHandle

Tags:

In my code I have an interface - lets say its called InterfaceName and its implementation called InterfaceImpl. Now when I dynamically try to obtain the InterfaceImpl using the following code:

object obj = Activator.CreateInstance("ProjectName","ProjectName.Folder.InterfaceImpl");
InterfaceName in = (InterfaceName)obj; //Error pops up here

I get the following error

Unable to cast object of type 'System.Runtime.Remoting.ObjectHandle' to type 'ProjectName.Folder.InterfaceName'.

Any suggestions on what might be going wrong ?