internal static ParseAssemblyResult ParseAssemblyName(string fullName, out ParsedAssemblyName parsedName) { parsedName = new ParsedAssemblyName(); int pos; ParseAssemblyResult res = ParseAssemblySimpleName(fullName, out pos, out parsedName.Name); if (res != ParseAssemblyResult.OK) { return(res); } else { const int ERROR_SXS_IDENTITIES_DIFFERENT = unchecked ((int)0x80073716); System.Collections.Generic.Dictionary <string, string> unknownAttributes = null; bool hasProcessorArchitecture = false; bool hasContentType = false; bool hasPublicKeyToken = false; string publicKeyToken; while (pos != fullName.Length) { string key = null; string value = null; if (!TryParseAssemblyAttribute(fullName, ref pos, ref key, ref value)) { return(ParseAssemblyResult.GenericError); } key = key.ToLowerInvariant(); switch (key) { case "version": if (parsedName.Version != null) { return(ParseAssemblyResult.DuplicateKey); } parsedName.Version = value; break; case "culture": if (parsedName.Culture != null) { return(ParseAssemblyResult.DuplicateKey); } if (!ParseCulture(value, out parsedName.Culture)) { return(ParseAssemblyResult.GenericError); } break; case "publickeytoken": if (hasPublicKeyToken) { return(ParseAssemblyResult.DuplicateKey); } if (!ParsePublicKeyToken(value, out publicKeyToken)) { return(ParseAssemblyResult.GenericError); } if (parsedName.HasPublicKey && parsedName.PublicKeyToken != publicKeyToken) { Marshal.ThrowExceptionForHR(ERROR_SXS_IDENTITIES_DIFFERENT); } parsedName.PublicKeyToken = publicKeyToken; hasPublicKeyToken = true; break; case "publickey": if (parsedName.HasPublicKey) { return(ParseAssemblyResult.DuplicateKey); } if (!ParsePublicKey(value, out publicKeyToken)) { return(ParseAssemblyResult.GenericError); } if (hasPublicKeyToken && parsedName.PublicKeyToken != publicKeyToken) { Marshal.ThrowExceptionForHR(ERROR_SXS_IDENTITIES_DIFFERENT); } parsedName.PublicKeyToken = publicKeyToken; parsedName.HasPublicKey = true; break; case "retargetable": if (parsedName.Retargetable.HasValue) { return(ParseAssemblyResult.DuplicateKey); } switch (value.ToLowerInvariant()) { case "yes": parsedName.Retargetable = true; break; case "no": parsedName.Retargetable = false; break; default: return(ParseAssemblyResult.GenericError); } break; case "processorarchitecture": if (hasProcessorArchitecture) { return(ParseAssemblyResult.DuplicateKey); } hasProcessorArchitecture = true; switch (value.ToLowerInvariant()) { case "none": parsedName.ProcessorArchitecture = ProcessorArchitecture.None; break; case "msil": parsedName.ProcessorArchitecture = ProcessorArchitecture.MSIL; break; case "x86": parsedName.ProcessorArchitecture = ProcessorArchitecture.X86; break; case "ia64": parsedName.ProcessorArchitecture = ProcessorArchitecture.IA64; break; case "amd64": parsedName.ProcessorArchitecture = ProcessorArchitecture.Amd64; break; case "arm": parsedName.ProcessorArchitecture = ProcessorArchitecture.Arm; break; default: return(ParseAssemblyResult.GenericError); } break; case "contenttype": if (hasContentType) { return(ParseAssemblyResult.DuplicateKey); } hasContentType = true; if (!value.Equals("windowsruntime", StringComparison.OrdinalIgnoreCase)) { return(ParseAssemblyResult.GenericError); } parsedName.WindowsRuntime = true; break; default: if (key.Length == 0) { return(ParseAssemblyResult.GenericError); } if (unknownAttributes == null) { unknownAttributes = new System.Collections.Generic.Dictionary <string, string>(); } if (unknownAttributes.ContainsKey(key)) { return(ParseAssemblyResult.DuplicateKey); } unknownAttributes.Add(key, null); break; } } return(ParseAssemblyResult.OK); } }