private Exception UncachedTryResolveCaseSensitive(ReflectionDomain reflectionDomain, RuntimeAssembly currentAssembly, out RuntimeType result) { result = null; foreach (QScopeDefinition scopeDefinition in currentAssembly.AllScopes) { MetadataReader reader = scopeDefinition.Reader; ScopeDefinitionHandle scopeDefinitionHandle = scopeDefinition.Handle; NamespaceDefinition namespaceDefinition; if (!TryResolveNamespaceDefinitionCaseSensitive(reader, scopeDefinitionHandle, out namespaceDefinition)) { continue; } // We've successfully drilled down the namespace chain. Now look for a top-level type matching the type name. IEnumerable <TypeDefinitionHandle> candidateTypes = namespaceDefinition.TypeDefinitions; foreach (TypeDefinitionHandle candidateType in candidateTypes) { TypeDefinition typeDefinition = candidateType.GetTypeDefinition(reader); if (typeDefinition.Name.StringEquals(_name, reader)) { result = reflectionDomain.ResolveTypeDefinition(reader, candidateType); return(null); } } // No match found in this assembly - see if there's a matching type forwarder. IEnumerable <TypeForwarderHandle> candidateTypeForwarders = namespaceDefinition.TypeForwarders; foreach (TypeForwarderHandle typeForwarderHandle in candidateTypeForwarders) { TypeForwarder typeForwarder = typeForwarderHandle.GetTypeForwarder(reader); if (typeForwarder.Name.StringEquals(_name, reader)) { RuntimeAssemblyName redirectedAssemblyName = typeForwarder.Scope.ToRuntimeAssemblyName(reader); AssemblyQualifiedTypeName redirectedTypeName = new AssemblyQualifiedTypeName(this, redirectedAssemblyName); return(redirectedTypeName.TryResolve(reflectionDomain, null, /*ignoreCase: */ false, out result)); } } } { String typeName = this.ToString(); String message = SR.Format(SR.TypeLoad_TypeNotFound, typeName, currentAssembly.FullName); return(ReflectionCoreNonPortable.CreateTypeLoadException(message, typeName)); } }
public static TypeLoadException CreateTypeLoadException(string typeName, string assemblyName) { string message = SR.Format(SR.TypeLoad_TypeNotFoundInAssembly, typeName, assemblyName); return(ReflectionCoreNonPortable.CreateTypeLoadException(message, typeName)); }