ReflectorResolveType(TypeName, ResolveTypeOptions) Method

Gets the Type with the specified typeName. When no assembly is defined in typeName, the type can be defined in any loaded assembly.

Definition

Namespace: KGySoft.Reflection
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
C#
[CLSCompliantAttribute(false)]
public static Type? ResolveType(
	TypeName typeName,
	ResolveTypeOptions options = ResolveTypeOptions.TryToLoadAssemblies|ResolveTypeOptions.AllowPartialAssemblyMatch
)

Parameters

typeName  TypeName
A pre-parsed TypeName instance with or without assembly name.
options  ResolveTypeOptions  (Optional)
The options for resolving the type. This parameter is optional.
Default value: TryToLoadAssemblies, AllowPartialAssemblyMatch.

Return Value

Type
The resolved Type, or if the ThrowError flag is not enabled in options and typeName could not be resolved with the provided options.

Remarks

  Security Note

The default value of the options parameter allows loading assemblies if typeName is an assembly qualified name. This behavior is compatible with the Type.GetType method but can be a security risk if typeName is from an untrusted source, e.g. file, user input, remote service, database, etc. In such cases do not enable the TryToLoadAssemblies flag so the type can be resolved from the already loaded assemblies only.

typeName can be generic and may contain fully or partially defined assembly names.

See Also