zoukankan      html  css  js  c++  java
  • Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information

    通过添加如下的代码catch exception获取具体缺失的库的名称:

    using System.IO;
    using System.Reflection;
    using System.Text;
    
    try
    {
        //The code that causes the error goes here.
    }
    catch (ReflectionTypeLoadException ex)
    {
        StringBuilder sb = new StringBuilder();
        foreach (Exception exSub in ex.LoaderExceptions)
        {
            sb.AppendLine(exSub.Message);
            FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
            if (exFileNotFound != null)
            {                
                if(!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                {
                    sb.AppendLine("Fusion Log:");
                    sb.AppendLine(exFileNotFound.FusionLog);
                }
            }
            sb.AppendLine();
        }
        string errorMessage = sb.ToString();
        //Display or log the error based on your application.
    }
  • 相关阅读:
    IO流
    简单JSON
    开发流程
    命名规范
    策略模式
    Git的使用
    Markdown的使用
    代理模式
    装饰者模式
    POJ 2976 3111(二分-最大化平均值)
  • 原文地址:https://www.cnblogs.com/csstudy/p/11584108.html
Copyright © 2011-2022 走看看