为什么加载这个DLL DevExpress.ExpressApp?

时间:2016-10-19 22:28:17

标签: winforms devexpress mef gac

我正在尝试将插件部署到客户端。 我们使用MEF,导入,导出属性。我使用Export并且客户端导入它 我的应用程序使用DevExpress XtraGrid,XtraEditors和许多其他DevExpress DLL(见截图),System.Data.Services。 尽管提供了所有这些必需的DLL及其许多依赖项,但该插件似乎仍然需要DevExpress.ExpressApp。绝对不需要DevExpress.ExpressApp及其所有其他依赖项。

由于客户端一直抱怨他们有FileNotFound异常,我决定创建一个测试项目来导入我自己的插件。这是我测试客户理论的测试代码,他得到的是以下内容。

System.IO.FileNotFoundException: Could not load file or assembly 'DevExpress.ExpressApp.v14.2, Version=14.2.7.0, 


Our Plugin
     [Export(typeof (ISomething))]
        public class MyClass : ISomething
        {

    }
TESTER
     class Program
    {
           [ImportMany]
        public IEnumerable<ISomething> Somethings { get; set; }
        static void Main(string[] args)
        {

            var rp = new Program();
            rp.Run();


        }
        public void Run()
        {
            Compose();

        }
        public void Compose()
        {
            try
            {
                AppDomain.CurrentDomain.FirstChanceException += FirstChanceHandler;
                AggregateCatalog aggregatecatalogue = new AggregateCatalog();
                aggregatecatalogue.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory));
                CompositionContainer container = new CompositionContainer(aggregatecatalogue);
                CompositionBatch batch = new CompositionBatch();
                batch.AddPart(this);
                container.Compose(batch);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        static void FirstChanceHandler(object source, FirstChanceExceptionEventArgs e)
        {
            System.Text.StringBuilder msg = new System.Text.StringBuilder();
            msg.AppendLine(e.Exception.GetType().FullName);
            msg.AppendLine(e.Exception.Message);
            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
            msg.AppendLine(st.ToString());
            msg.AppendLine();
            String desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string logFilePath = String.Format("{0}\\{1}", desktopPath, "logfile.txt");
            System.IO.File.AppendAllText(logFilePath, msg.ToString());

        }

果然,我在输出窗口中看到它确实加载了这个DLL以及一些与GAC的ExpressApp相关的依赖项。 问题:如何确定ExpressApp需要的位置和原因? 我可以简单地传递DLL,但随后它会继续关于TON的依赖关系,我已经知道为什么需要这些依赖关系。

enter image description here

1 个答案:

答案 0 :(得分:1)

有用于检查托管程序集依赖关系的工具。 MS Windows SDK包含 ildasm.exe 实用程序。您可能已将其安装在:

C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v8.0A \ bin \ NETFX 4.0 Tools \ ildasm.exe

当我遇到类似的问题(这是dll版本不匹配)时,我也使用了cygwin&#39; grep&#39;从命令行搜索所有DX和我们的自定义程序集中缺少的依赖项字符串,以找到引用缺少的依赖项DLL版本的实际.dll文件。然后在ildasm.exe中打开它并双击MANIFEST树节点。在那里我看到了对我没有的.dll版本的引用。

您可以按照相同的步骤尝试跟踪缺少的依赖项。运行&#34; DevExpress.ExpressApp&#34;对项目的bin目录中的所有DX dll进行字符串搜索,如果找到结果,请使用ildasm.exe打开报告的文件

请注意,很可能你没有'grep&#39;从安装的https://www.cygwin.com/包中,使用您可以使用的字符串搜索实用程序。

还有其他第三方工具可用于检查dll依赖项,但这些工具必须单独安装,而ildasm.exe是Windows SDK的一部分。请参阅此问题以获得其他工具的答案:​​

How do I determine the dependencies of a .NET application?

<强>更新

如果您没有在bin文件夹中拥有所有DX库,因为您的应用程序是插件并直接从GAC使用DX库,那么您可以在DX安装文件夹中搜索DevExpress.ExpressApp引用,我的情况:

C:\ Program Files(x86)\ DevExpress 15.2 \ Components \ Bin \ Framework

我已将上述文件夹内容复制到临时文件夹,删除了所有语言环境子文件夹以及所有DevExpress.ExpressApp。* dll,然后运行命令:

grep -nr "DevExpress.ExpressApp"

产生了以下结果:

Binary file DevExpress.EasyTest.v15.2.dll matches
Binary file DevExpress.Persistent.Base.v15.2.dll matches
Binary file DevExpress.Persistent.BaseImpl.EF.v15.2.dll matches
Binary file DevExpress.Persistent.BaseImpl.v15.2.dll matches
Binary file DevExpress.Workflow.Activities.v15.2.Design.dll matches
Binary file DevExpress.Workflow.Activities.v15.2.dll matches

查看您的插件或部署插件的主机应用程序是否使用了上述任何dll。

HTH