我的代码如下:
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { AppDomain ad = AppDomain.CreateDomain("New domain"); Worker remoteWorker = (Worker)ad.CreateInstanceAndUnwrap( typeof(Worker).Assembly.FullName, "Worker");//抛出TypeLoadException异常 Console.ReadLine(); } } public class Worker : MarshalByRefObject { public void PrintDomain() { Console.WriteLine("Object is executing in AppDomain \"{0}\"", AppDomain.CurrentDomain.FriendlyName); } } }
这是怎么回事,请大家看看。