GetType Method (String, Boolean)
Collapse the table of content
Expand the table of content

Module.GetType Method (String, Boolean)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns the specified type, searching the module with the specified case sensitivity.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

Public Overridable Function GetType ( _
	className As String, _
	ignoreCase As Boolean _
) As Type


Type: System.String
The name of the type to locate. The name must be fully qualified with the namespace.
Type: System.Boolean
true to perform a case-insensitive search; otherwise, false.

Return Value

Type: System.Type
The given type, if the type is in this module; otherwise, Nothing.


className is Nothing.


The class initializers are invoked and an exception is thrown.


className is a zero-length string.


className requires a dependent assembly that could not be found.


className requires a dependent assembly that was found but could not be loaded.


The current assembly was loaded into the reflection-only context, and className requires a dependent assembly that was not preloaded.


className requires a dependent assembly, but the file is not a valid assembly.


className requires a dependent assembly which was compiled for a version of the runtime later than the currently loaded version.


If the type has been forwarded to another assembly, it is still returned by this method.

A type can be retrieved from a specific module using Module.GetType. Calling Module.GetType on the module that contains the manifest will not search the entire assembly. To retrieve a type from an assembly, regardless of which module it is in, you must call Assembly.GetType.

Version Notes

Windows Phone

 GetType does not throw ArgumentException when an empty string is passed as className. Instead, it returns Nothing.

The following example gets a type in the currently executing module, specifying a string that has incorrect casing and specifying true for the ignoreCase parameter so that case is ignored.

Imports System.Reflection

Class Example
    Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
        Dim moduleArray() As [Module]

        moduleArray = [Assembly].GetExecutingAssembly().GetModules()

        Dim myModule As [Module] = moduleArray(0)

        Dim myType As Type

        myType = myModule.GetType("SILVERlightApplication.example", True)
        outputBlock.Text += String.Format("Found type: {0}" & vbLf, myType.ToString())
    End Sub 
End Class 

' This example produces output similar to the following:
'Found type: SilverlightApplication.Example

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft