Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TypeFinder Sample (Get Type Information) 

Download sample

This sample provides a command-line interface to get information about types in the environment. Sometimes locating a specific type's namespace or DLL can be difficult, and once you locate the type, the documentation may be unavailable or out of date. This utility provides a simple way to determine what types are available, what module they are in, and what interfaces, methods, fields, properties, and events are available on the type. This sample also provides an introduction to reflection.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

Building and Running the Sample

To open the sample file in Solution Explorer

  1. Click Download Sample.

    The File Download message box appears.

  2. Click Open, and on the left column of the zip folder window, click Extract all files.

    The Extraction Wizard opens.

  3. Click Next. You can change the directory that the files will be extracted to, and then click Next again.

    Make sure that the Show extracted files check box is selected, and click Finish.

  4. Double-click the sample's .sln file.

    The sample solution is displayed in Solution Explorer. You might get a security warning that says the solution location is not trusted. Click OK to continue.

To build and run the sample from the development environment

  1. On the Build menu, click Build Solution, or press CTRL+SHIFT+B.

  2. Press F5 to run the sample.

To build and run the sample from the command line

  1. Type BUILD.bat.

    NoteNote

    For more information, see Building from the Command Line (Visual J#).

  2. Type TypeFinder, and press ENTER.

  3. To find the location of each type with a word in its name, type TypeFinder word from the command line.

Classes and Technologies in the Sample

The following classes and technologies are used in this sample.

Reflection
Class/Technology Description

Assembly

Loads assemblies into the AppDomain so that they can be searched for types.

Module

Gets types from the assembly or module for comparison to the search string.

Type

Gets type information such as name, namespace, and members.

PropertyInfo

Finds information about properties in types.

EventInfo

Finds information about events in types.

FieldInfo

Finds information about fields in types.

MethodInfo

Finds information about methods in types.

I/O
Class/Technology Description

TextWriter

Used by the IndentedWriter sample type to output (to the console, by default) in a generic fashion.

Text
Class/Technology Description

StringBuilder

Used by the IndentedWriter sample type to create a string.

String

Used throughout the sample to find format strings, find substrings, uppercase strings, for example.

Collections
Class/Technology Description

ArrayList

Used by the sample to manage a list of strings.

Registry
Class/Technology Description

Registry

Used to create an instance of the RegistryKey type for a subkey of the LocalMachine key.

RegistryKey

Used to read values from a key in the registry.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft