2012-04-26 62 views
4

我刚开始学习vb.net。 但我无法找出System.Type类的位置。 我GOOGLE了,但无法找到任何答案。 这里是我做的:Type类在哪里?

Module m 
Sub Main(ByVal e as String()) 
Dim ass as Assembly = Assembly.LoadFrom(e(0)) 
Dim assobj as Type() = ass.GetTypes() 
For Each m As Type In assobj 
Console.WriteLine(m.Name) 
next 

我改变了目录为C:\ WINDOWS \ Microsoft.NET \框架\ V2.0.50727>并提供System.dll中作为参数 但我无法找到Type类

那么,Type类是什么?

如果有什么不对,请忽略我的无知。 谢谢。再次

您好, 我有一个问题,我上面提到的这件事的目的是使类似于Java的javap.exe实用

一个控制台应用程序,如果你给的类全名作为参数,那么它应该打印大量的信息关于班级。

问题是 - 我怎么知道要加载哪个.dll文件,取决于我输入的类名(这就是我期望System.Type会在System.dll文件中的原因)

+0

http://msdn.microsoft.com/en-us/library/system.type.aspx说,这是在** mscorlib.dll **中。这有帮助吗?否则,你的意思是“在哪里”? – 2012-04-26 14:58:12

+0

感谢您的链接..我的意思是 - 如果它不是在System.dll中,那么其他.dll文件可以在。现在我知道它在mscorlib.dll中。 – user1247808 2012-04-26 16:09:11

+0

@ user1247808在StackOverflow上,通常当答案对你有帮助时,你可以选择一个你认为是“答案”的答案,并用绿色复选标记来标记答案,将这个问题设置为“已回答” – 2012-04-26 19:02:33

回答

2

我用ILSpy(免费工具)来看看。它是在mscorlib.dll

+0

非常感谢。 – user1247808 2012-04-26 16:05:36

2

像Michal和Mr Lister表示它在mscorlib.dll。

我发现它虽然以不同的方式,如果把你的代码

Dim assobj as Type() = ass.GetTypes() 

和Word类型,然后按右键点击“转到定义”(快捷键F12)

默认显示是VB.net & C#略有不同。 (对我来说,反正)

对于VB.Net:

你会看到对象浏览器,你可以注意到类型是系统
Definition of Type in Object Browser

的成员,如果您单击系统,您会注意到它是mscorlib的成员。如果您点击mscorlib,那么您可以看到DLL实际存储的位置。

Definition of System in Object Browser


如果您使用的是C#,那么你将看到:

#region Assembly mscorlib.dll, v4.0.30319 
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\mscorlib.dll 
#endregion 

using System.Diagnostics; 
using System.Globalization; 
using System.Reflection; 
using System.Runtime; 
using System.Runtime.InteropServices; 
using System.Security; 

namespace System 
{ 
    // Summary: 
    //  Represents type declarations: class types, interface types, array types, 
    //  value types, enumeration types, type parameters, generic type definitions, 
    //  and open or closed constructed generic types. 
    [Serializable] 
    [ClassInterface(ClassInterfaceType.None)] 
    [ComDefaultInterface(typeof(_Type))] 
    [ComVisible(true)] 
    public abstract class Type : MemberInfo, _Type, IReflect 
    { 
     //snip 
    } 
} 
+0

感谢您的信息 – user1247808 2012-04-26 16:09:33