开发者

Create a application like Visual studio object Browser

I want to develop an application like Visual studio Object Browser, i.e. user will enter something like System.Text namespace or system classes. After button click, we have to find out all classes, functions, properties etc. inside the "System.Text".

I tried the following, but that failed.

       开发者_高级运维 Assembly SampleAssembly;
        SampleAssembly = Assembly.Load("System.Text");

        Type[] Types = SampleAssembly.GetTypes();
        // Display all the types contained in the specified assembly.
        StringBuilder str = new StringBuilder();

        foreach (Type oType in Types)
        {
            str.Append(oType.Name.ToString() + "</br>");
        }
        divAsseblyData.InnerHtml = str.ToString();


'System.Text' is a namespace not an assembly so i assume you want to load the assembly 'System'.

To use Assembly.Load() with a string parameter you need to pass the fully qualified name of the assembly.

To obtain the fully qualified name you can do something like this:

Assembly SampleAssembly;
SampleAssembly = Assembly.Load(typeof(System.Activator).Assembly.FullName);
// get the type of some random object in the assembly (Activator) and then
// call .Assembly.FullName which returns the fully qualified name of the assembly

Or you can press Win + R, type "Assembly" and enter, then right click -> proprieties on the assembly which you need and set manually the proprieties in code in the format:

"mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

SampleAssembly = Assembly.Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜