在调试.NET程序集时,有没有办法找到包含Autos,Locals或Watch窗口中所见变量的类型定义的程序集?例如(显然这只是出于示例目的),如果我在Watch窗口中看到Type列为//this is for send message
int main(int argc,char **argv)
{
int udpsocket;
int res;
char buf[50];
struct sockaddr_in saddr;
bzero(&saddr,sizeof(saddr));
// 初始化地址结构体变量
saddr.sin_family = AF_INET;
saddr.sin_port = htons(5001);
saddr.sin_addr.s_addr = inet_addr(argv[1]);
// 创建udp套接字
udpsocket = socket(AF_INET,SOCK_DGRAM,0);
if(udpsocket == -1)
{
perror("create udp socket failed!\n");
return -1;
}
// 将套接字的属性设置为可以广播
int on = 1;
setsockopt(udpsocket, SOL_SOCKET, SO_BROADCAST, &on, sizeof on);
setsockopt(udpsocket,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
int ret = sizeof(struct sockaddr);
while(1)
{
bzero(buf,50);
printf("please input a message !\n");
scanf("%s",buf);
sendto(udpsocket,buf,50,0,(struct sockaddr *)&saddr,ret);
}
close(udpsocket);
return 0;
}
的变量,我有办法让Visual Studio告诉我{{1} }是在System.Type
程序集中定义的吗?
编辑:我不需要能够在 Watch窗口中执行(虽然这样会很好!),只是从Visual Studio中的某个地方开始。
答案 0 :(得分:0)
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