gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 11:59:09 25 4
gpt4 key购买 nike

我创建了一个图表 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com