确定包含“自动/局部变量/监视”窗口中变量类型的定义的程序集



在调试 .NET 程序集时,有没有办法找到包含"自动"、"局部变量"或"监视"窗口中看到的变量的类型定义的程序集?例如(显然,这只是出于示例目的),如果我在"监视"窗口中看到一个变量,其"类型"列显示System.Type,有没有办法让Visual Studio告诉我System.Type是在mscorlib程序集中定义的?

编辑:我不需要能够从"监视"窗口执行此操作(尽管这会很好!),只需Visual Studio中的某个位置即可。

Damien_The_Unbeliever的评论让我想到了一个解决方案:在"即时"窗口中执行typeof(<type>)将吐出结果的字符串表示形式,其中包含我需要的一切!

例如:

typeof(System.Type)
{Name = "Type" FullName = "System.Type"}
    Assembly: {mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
    AssemblyQualifiedName: "System.Type, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    Attributes: Public | Abstract | Serializable | BeforeFieldInit
    BaseType: {Name = "MemberInfo" FullName = "System.Reflection.MemberInfo"}
    Cache: {System.RuntimeType.RuntimeTypeCache}
    ContainsGenericParameters: false
    CustomAttributes: Count = 0x00000005
    DeclaredConstructors: {System.Reflection.ConstructorInfo[0x00000002]}
    DeclaredEvents: {System.Reflection.EventInfo[0x00000000]}
    DeclaredFields: {System.Reflection.FieldInfo[0x00000009]}
    DeclaredMembers: {System.Reflection.MemberInfo[0x0000010e]}
    DeclaredMethods: {System.Reflection.MethodInfo[0x000000c1]}
    DeclaredNestedTypes: {System.Reflection.TypeInfo.<get_DeclaredNestedTypes>d__23}
    DeclaredProperties: {System.Reflection.PropertyInfo[0x00000042]}
    DeclaringMethod: '((System.RuntimeType)(typeof(System.Type))).DeclaringMethod' threw an exception of type 'System.InvalidOperationException'
    DeclaringType: null
    DomainInitialized: false
    ForwardCallBinder: {System.OleAutBinder}
    FullName: "System.Type"
    GUID: {6c9863dc-7207-327f-a048-c3bb63474bfc}
    GenericCache: null
    GenericParameterAttributes: '((System.RuntimeType)(typeof(System.Type))).GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'
    GenericParameterPosition: '((System.RuntimeType)(typeof(System.Type))).GenericParameterPosition' threw an exception of type 'System.InvalidOperationException'
    GenericTypeArguments: {System.Type[0x00000000]}
    GenericTypeParameters: {System.Type[0x00000000]}
    HasElementType: false
    HasProxyAttribute: false
    ImplementedInterfaces: {System.Type[0x00000004]}
    InvocationFlags: INVOCATION_FLAGS_INITIALIZED
    IsAbstract: true
    IsAnsiClass: true
    IsArray: false
    IsAutoClass: false
    IsAutoLayout: true
    IsByRef: false
    IsCOMObject: false
    IsClass: true
    IsConstructedGenericType: false
    IsContextful: false
    IsEnum: false
    IsExplicitLayout: false
    IsExportedToWindowsRuntime: false
    IsGenericParameter: false
    IsGenericType: false
    IsGenericTypeDefinition: false
    IsImport: false
    IsInterface: false
    IsLayoutSequential: false
    IsMarshalByRef: false
    IsNested: false
    IsNestedAssembly: false
    IsNestedFamANDAssem: false
    IsNestedFamORAssem: false
    IsNestedFamily: false
    IsNestedPrivate: false
    IsNestedPublic: false
    IsNotPublic: false
    IsPointer: false
    IsPrimitive: false
    IsPublic: true
    IsSealed: false
    IsSecurityCritical: false
    IsSecuritySafeCritical: false
    IsSecurityTransparent: true
    IsSerializable: true
    IsSpecialName: false
    IsSzArray: false
    IsUnicodeClass: false
    IsValueType: false
    IsVisible: true
    IsWindowsRuntimeObject: false
    MemberType: TypeInfo
    MetadataToken: 0x0200013d
    Module (System.Reflection.MemberInfo): {CommonLanguageRuntimeLibrary}
    Module: {CommonLanguageRuntimeLibrary}
    Name: "Type"
    Namespace: "System"
    NeedsReflectionSecurityCheck: false
    ReflectedType: null
    RemotingCache: {System.Runtime.Remoting.Metadata.RemotingTypeCachedData}
    StructLayoutAttribute: {System.Runtime.InteropServices.StructLayoutAttribute}
    TypeHandle: {System.RuntimeTypeHandle}
    TypeInitializer: {Void .cctor()}
    UnderlyingSystemType: {Name = "Type" FullName = "System.Type"}
    m_cache: {2956100}
    m_cachedData: {System.Runtime.Remoting.Metadata.RemotingTypeCachedData}
    m_handle: {1930553888}
    m_invocationFlags: INVOCATION_FLAGS_INITIALIZED
    m_keepalive: null

最新更新