c# - VS C# 中的依赖 hell ,找不到依赖项

标签 c# visual-studio dependencies .net-assembly

我创建了一个图表 C# 库(我们称之为 chartlibrary),它本身依赖于多个第三方 dll 文件。

在另一个可执行项目(我们称之为 chartuser)中,我引用了 chartlibrary 项目(这两个项目都位于 Visual Studio 中的同一个解决方案中)。

编译后可以看到chartlibrary引用的所有第三方dll文件也包含在chartuser的bin/Debug文件夹中。但是,我收到一个运行时错误,它基本上指出了 chartlibrary 中的某些引用无法解析的事实。然后我试图通过

获得更好的想法
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
        var assemblyFileName = args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll";
        var assemblyPathFileName = _currentPluginPath + @"\" + assemblyFileName;

        if (File.Exists(assemblyPathFileName))
        {
            return Assembly.Load(File.ReadAllBytes(assemblyPathFileName));
        }

        return null;
    }

问题是 RequestingAssembly 为 null 并且 Name 非常神秘。

我做错了什么,即使所有的 dll 都在可执行项目的 bin/Debug 文件夹中,也找不到引用的 dll 并且无法解析程序集?

最佳答案

Fix: A fix for the third party library related to their obfuscation engine solved the issue.


.NET 依赖项:也许浏览一下这个旧答案:How do I determine the dependencies of a .NET application? - 并检查任何 list 文件?

调试:The Microsoft Assembly Binding Log Viewer可以告诉你运行时发生了什么。通过 Visual Studio 开发人员命令提示符 启动它(只需搜索“开发人员命令”,输入 “FUSLOGVW.exe” 并按 Enter)。也可能略读一下:How the Runtime Locates Assemblies .

我不太熟悉它们的用途,但还有一些更进一步的工具(大多数都有超越依赖项的进一步用途):

应用启动 list :

运行时:如果问题发生在另一台计算机上,则检查列表中最先出现的明显运行时:.Net.Net Core, Java, Silverlight, Direct X, VC++ Runtime, MS-XML(旧版)Crystal ReportsMicrosoft Report ViewerSQL Server/Database Runtimes 等...加上任何涉及 COM 注册的内容,显然还有您引用的任何第三方框架组件(COM、COM Interop、GAC、程序集等)。


其他链接:

关于c# - VS C# 中的依赖 hell ,找不到依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57884104/

相关文章:

c# - 验证空文本框

c# - 如何在 ASP.NET MVC 5 中为特定 Controller 指定路由选项

c# - 将 Datagrid 单元格原始值与 CellEditEnding 事件中的编辑值进行比较

c# - 获取表达式中成员的类型

visual-studio - ReSharper - 将设置保存到文件

c# - 如何在 MonoDevelop/Visual Studio 中跳过加载项目

c++ - 恢复调试 session 不构建更改 VS2012

java - eclipse : Maven - context menu does not display the option "Search dependency for..."

Grails 不识别任何在线/插件依赖

c++ - 如何以跨平台方式+CMake自动下载C++依赖?