//使用System.Reflection,查找System.ServiceModel的异常类型
public void ConsoleException()
{
try
{
Assembly asm = Assembly.GetExecutingAssembly();
foreach (AssemblyName item in asm.GetReferencedAssemblies())
{
if (item.Name != "System.ServiceModel") continue;
foreach (Type t in Assembly.Load(item).GetTypes())
{
if (t.Name.EndsWith("Exception"))
{
Console.WriteLine(t.Name);
}
}
break;
}
}
catch (Exception ex)
{
Console.WriteLine( ex.Message);
}
}