跨Appdomain读取对象时,好像要封送,对象可序列化或者实现MarshalByRefObject类。
解决方案 »
- 关于几种运算符号的运算速度
- 高手:vs2005挂OCX报表系统报:ActiveFormX_webocxProj1.ocx的自动注册失败
- WCF问题?
- 请教高手看看这种情况怎么用c#实现,想的我头都大了。
- 如何通过点击打开helpProvide控件的帮助文档
- 一个C#引用函数的问题!
- 兄弟姐妹们帮小弟解决这个问题 谢谢了
- 我c#时遇到的一个问题
- comboBox 数据邦定问题! 大家都来看看.帮下我
- 什么时候确定用服务器控件,什么时候确定用一般网页控件?
- [求助] TextBox选择文本问题
- .net dll的安装包用Inno Setup还是Visual Studio Installer,哪个好?
internal static class ExceptionTree {
public static void Go() {
// Explicitly load the assemblies that we want to reflect over
LoadAssemblies(); // Recursively build the class hierarchy as a hyphen-separated string
Func<Type, String> ClassNameAndBase = null;
ClassNameAndBase = t => "-" + t.FullName +
((t.BaseType != typeof(Object)) ? ClassNameAndBase(t.BaseType) : String.Empty); // Define our query to find all the public Exception-derived types in this AppDomain's assemblies
var exceptionTree =
(from a in new[] { typeof(Exception).Assembly } // AppDomain.CurrentDomain.GetAssemblies()
from t in a.GetExportedTypes()
where t.IsClass && t.IsPublic && typeof(Exception).IsAssignableFrom(t)
let typeHierarchyTemp = ClassNameAndBase(t).Split('-').Reverse().ToArray()
let typeHierarchy = String.Join("-", typeHierarchyTemp, 0, typeHierarchyTemp.Length - 1)
orderby typeHierarchy
select typeHierarchy).ToArray(); // Display the Exception tree
Console.WriteLine("{0} Exception types found.", exceptionTree.Length);
foreach (String s in exceptionTree) {
// For this Exception type, split its base types apart
String[] x = s.Split('-'); // Indent based on # of base types and show the most-derived type
Console.WriteLine(new String(' ', 3 * (x.Length - 1)) + x[x.Length - 1]);
}
}
private static void LoadAssemblies() {
String[] assemblies = {
"System, PublicKeyToken={0}",
"System.Core, PublicKeyToken={0}",
"System.Data, PublicKeyToken={0}",
"System.Design, PublicKeyToken={1}",
"System.DirectoryServices, PublicKeyToken={1}",
"System.Drawing, PublicKeyToken={1}",
"System.Drawing.Design, PublicKeyToken={1}",
"System.Management, PublicKeyToken={1}",
"System.Messaging, PublicKeyToken={1}",
"System.Runtime.Remoting, PublicKeyToken={0}",
"System.Security, PublicKeyToken={1}",
"System.ServiceProcess, PublicKeyToken={1}",
"System.Web, PublicKeyToken={1}",
"System.Web.RegularExpressions, PublicKeyToken={1}",
"System.Web.Services, PublicKeyToken={1}",
"System.Windows.Forms, PublicKeyToken={0}",
"System.Xml, PublicKeyToken={0}",
}; String EcmaPublicKeyToken = "b77a5c561934e089";
String MSPublicKeyToken = "b03f5f7f11d50a3a"; // Get the version of the assembly containing System.Object
// We'll assume the same version for all the other assemblies
Version version = typeof(System.Object).Assembly.GetName().Version; // Explicitly load the assemblies that we want to reflect over
foreach (String a in assemblies) {
String AssemblyIdentity =
String.Format(a, EcmaPublicKeyToken, MSPublicKeyToken) +
", Culture=neutral, Version=" + version;
Assembly.Load(AssemblyIdentity);
}
}
}