【发布时间】:2022-01-23 11:24:35
【问题描述】:
我有点失落。我已经在这个项目上工作了 2 年,我决定重新安装我的操作系统以再次获得更流畅的工作体验。
我使用的安装程序是 Windows 10 和 Visual Studio 2022 社区版。项目本身是用.net 4.6.1编写的
自从重新安装操作系统后,我的 C# 项目在启动时崩溃。
Topshelf.HostFactory Error: 0 : The service terminated abnormally,
System.IO.FileNotFoundException: Die Datei oder Assembly
"System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral,
PublicKeyToken=(token)" oder eine Abhängigkeit wurde nicht gefunden.
我重新安装并更新了所有 NuGet 包,但我不知道如何修复 System.Runtime.InteropServices 错误。
根据其他资源InteropService 需要.net 4.7.1 但这并没有解决我的问题。
当我尝试手动添加 System.Runtime.InteropServices 时,它没有被列出(我猜是因为它一直在寻找 .NET Framework 4.6.1:
【问题讨论】:
-
你在安装vs时勾选了正确的dotnet框架版本吗?
-
我安装了 .net 6.x,之后又安装了 4.6.1 和 4.7.1
-
还要检查
App.config中的程序集绑定:System.Runtime.InteropServices可能存在版本重定向 -
为什么要针对 .NET 4.6.1?我不相信有任何充分的理由继续使用那个旧版本。为什么不能改为以 .NET Framework 4.8 为目标?
-
@kyrylomyr
<dependentAssembly> <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly>在我的app.config中
标签: c#