internal string GetClassInfo(string assemblyName, string className, string strField) { string ret = strField; if (!String.IsNullOrEmpty(assemblyName) && !String.IsNullOrEmpty(className)) { string callingDomainName = AppDomain.CurrentDomain.FriendlyName;//Thread.GetDomain().FriendlyName; AppDomain ad = AppDomain.CreateDomain("Test Domain"); ProxyObject obj = (ProxyObject)ad.CreateInstanceFromAndUnwrap(callingDomainName, "XXNamespace.ProxyObject"); obj.LoadAssembly(assemblyName); //obj.Invoke("TestDll.Class1", "Test", "It's a test"); ret = obj.GetClassInfo(className, strField); AppDomain.Unload(ad); } return ret; } class ProxyObject : MarshalByRefObject { Assembly assembly = null; public void LoadAssembly(string assemblyName) { assembly = Assembly.LoadFile(assemblyName); } public string GetClassInfo(string className, string strField) { string ret = strField; Type type = assembly.GetType(className, true, true); if (type != null) { FieldInfo fieldinfo = type.GetField(strField, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static); //return (String)fieldinfo.GetValue(assembly); ret = (String)fieldinfo.GetValue(null); } return ret; } public bool Invoke(string fullClassName, string methodName, params Object[] args) { if (assembly == null) return false; Type tp = assembly.GetType(fullClassName); if (tp == null) return false; MethodInfo method = tp.GetMethod(methodName); if (method == null) return false; Object obj = Activator.CreateInstance(tp); method.Invoke(obj, args); return true; } }