Exemplo n.º 1
0
        private static ResolutionAttempt GetResolutionAttempt(AssemblyName assemblyName, ResolutionStage stage, AssemblyLoadContext alc, ResolutionResult result, Assembly resultAssembly = null)
        {
            AssemblyName resultAssemblyName = null;
            string       resultAssemblyPath = string.Empty;

            if (resultAssembly != null)
            {
                resultAssemblyName = resultAssembly.GetName();
                resultAssemblyPath = resultAssembly.Location;
            }

            return(GetResolutionAttempt(assemblyName, stage, alc, result, resultAssemblyName, resultAssemblyPath));
        }
Exemplo n.º 2
0
        private static ResolutionAttempt GetResolutionAttempt(AssemblyName assemblyName, ResolutionStage stage, AssemblyLoadContext alc, ResolutionResult result, AssemblyName resultAssemblyName, string resultAssemblyPath, string errorMessage = null)
        {
            var attempt = new ResolutionAttempt()
            {
                AssemblyName        = assemblyName,
                Stage               = stage,
                AssemblyLoadContext = alc == AssemblyLoadContext.Default ? DefaultALC : alc.ToString(),
                Result              = result,
                ResultAssemblyName  = resultAssemblyName,
                ResultAssemblyPath  = resultAssemblyPath
            };

            if (!string.IsNullOrEmpty(errorMessage))
            {
                attempt.ErrorMessage = errorMessage;
            }
            else
            {
                switch (result)
                {
                case ResolutionAttempt.ResolutionResult.AssemblyNotFound:
                    attempt.ErrorMessage = "Could not locate assembly";
                    break;

                case ResolutionAttempt.ResolutionResult.IncompatibleVersion:
                    attempt.ErrorMessage = $"Requested version {assemblyName.Version} is incompatible with found version {resultAssemblyName.Version}";
                    break;

                case ResolutionAttempt.ResolutionResult.MismatchedAssemblyName:
                    attempt.ErrorMessage = $"Requested assembly name '{assemblyName.FullName}' does not match found assembly name '{resultAssemblyName.FullName}'";
                    break;
                }
            }

            return(attempt);
        }
Exemplo n.º 3
0
 private static ResolutionAttempt GetResolutionAttempt(AssemblyName assemblyName, ResolutionStage stage, AssemblyLoadContext alc, string exceptionMessage)
 {
     return(GetResolutionAttempt(assemblyName, stage, alc, ResolutionResult.Exception, null, null, exceptionMessage));
 }