Runtime: COREHOST_TRACE 应该记录 AssemblyLoadContext

创建于 2019-04-16  ·  3评论  ·  资料来源: dotnet/runtime

背景
在 Windows 上,我正在与 .NET Core 全局工具集成,该工具又通过命令行参数assembly="c:\source\bin\Debug\netstandard2.0\JohnZabroski.Database.dll"加载程序集。 JohnZabroski.Database.dll传递地引用System.Data.SqlClient

问题
使用COREHOST_TRACE=1 ,我当前的 stderr 如下所示:

!!! Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
!!! +- Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621) ---> System.IO.FileLoadException: Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
   at System.AppDomain.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)

在尝试解决为什么找不到或找不到我的组装时,我发现以下博客文章相当令人生畏: https ://mattwarren.org/2016/07/04/How-the-dotnet-CLI-tooling-runs-your

我发现 .NET 4.6 中的 Assembly Fusion Log Viewer 工具更容易获得用户体验。 见: https ://github.com/dotnet/coreclr/issues/10379

可能相关
https://github.com/dotnet/coreclr/issues/15863 - 用户发现在 Linux 上调试程序集加载非常糟糕(已修复:https://github.com/dotnet/coreclr/pull/15831)

area-AssemblyLoader-coreclr enhancement

最有用的评论

这是绝对需要的。 它在我们的积压工作中,但不太可能成为 .NET Core 3.0。

所有3条评论

从@jeffschwMSFT 开始。 如果我错了,请修正area-

这是绝对需要的。 它在我们的积压工作中,但不太可能成为 .NET Core 3.0。

这是绝对需要的。 它在我们的积压工作中,但不太可能成为 .NET Core 3.0。

如果它“绝对需要”,为什么不在 Core 3.0 中? 发布新的和花哨的功能很棒,但微软的优势一直在于在这些功能不起作用时调试这些功能的工具。 排除装配绑定故障是一个关键工具,应该从一开始就内置到 Core 中,事实上它不是而且显然仍然没有被视为优先事项,这既令人担忧,坦率地说,也令人尴尬。

此页面是否有帮助?
0 / 5 - 0 等级