我有一个
.NET 8.0.401
应用程序,它使用以下依赖项:
>dotnet list xxx.csproj package
Project 'xxx' has the following package references
[net6.0-windows7.0]:
Top-level Package Requested Resolved
> Costura.Fody 5.7.0 5.7.0
> MahApps.Metro 2.4.10 2.4.10
> Newtonsoft.Json 13.0.3 13.0.3
> NLog 5.3.3 5.3.3
> System.Net.Http 4.3.4 4.3.4
> System.Text.RegularExpressions 4.3.1 4.3.1
我使用
global.json
文件强制使用 .NET 版本:
{
"sdk": {
"version": "8.0.401"
}
}
当我在调试或发布中编译并运行应用程序时,它工作正常。但是,有用户在运行应用程序时遇到以下错误:
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'PresentationFramework, Version=6.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'PresentationFramework, Version=6.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
用户也安装了
.NET 8
并且正在运行 Windows 11 Pro
,所以应该没问题。
我不知道为什么他会收到此错误,因为我什至没有引用
PresentationFramework
。我在 GUI 中使用 MahApps.Metro
,但这可能与 PresentationFramework
有关。我做了很多研究,但我不知道如何解决这个问题,特别是因为我无法重现它。
另一方面,我的只有
4.0.0
的 PresentationFramework
版本:
>gacutil /u PresentationFramework
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.0
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly: PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Unable to uninstall: assembly is required by one or more applications
Pending references:
SCHEME: <OPAQUE> ID: <{71F8EFBF-09AF-418D-91F1-52707CDFA274}> DESCRIPTION : <.NET Framework Redist Setup>
Number of assemblies uninstalled = 0
Number of failures = 0
这有关系吗?
我的开发机安装的.NET版本只有
.NET 8
和.NET 9
预览:
>dotnet --list-sdks
8.0.403 [C:\Program Files\dotnet\sdk]
9.0.100-preview.7.24407.12 [C:\Program Files\dotnet\sdk]
传递依赖也不包括
PresentationFramework
(dotnet list xxx.csproj package --include-transitive
)。
添加
PresentationFramework
NuGet 包引用似乎也没有意义。
.NET 运行时或全局程序集缓存以什么方式与此程序集加载问题相关?我是否必须对加载的 DLL 进行一些运行时跟踪或列出 .NET EXE 所需的 DLL,如果是,最好使用哪个应用程序?
Dependencies (x64)
还说我的机器上缺少PresentationFramework
,但我的.NET应用程序无论如何都可以在我的机器上正确运行:Fusion++
不会记录任何内容,因此我无法使用任何内容。