More specific
AppDomain domain = AppDomain.CreateDomain("New domain name"); //Do other things to the domain like set the security policy string pathToDll = @"C:\myDll.dll"; //Full path to dll you want to load Type t = typeof(TypeIWantToLoad); TypeIWantToLoad myObject = (TypeIWantToLoad)domain.CreateInstanceFromAndUnwrap(pathToDll, t.FullName);
If all that goes right (no exceptions), now you have an instance of TypeIWantToLoad loaded into your new domain. The instance you have is actually a proxy (since the actual object is in the new domain), but you can use it just like your regular object.
Note. As far as I know, TypeIWantToLoad should inherit from MarshalByRefObject.
Jon Turner Sep 18 '08 at 14:29 2008-09-18 14:29
source share