Netstandard 依赖 System.IO.FileNotFoundException [英] Netstandard dependency System.IO.FileNotFoundException

查看:26
本文介绍了Netstandard 依赖 System.IO.FileNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 .Net Framework 4.7 应用程序,该应用程序依赖于面向 .NET Standard 2.0 的解决方案中的另一个项目.

We have a .Net Framework 4.7 application, that has a dependency on another project in the solution which targets .NET Standard 2.0.

该项目再次依赖于通过私有 Nuget 存储库添加的另一个(外部).NET Standard 2.0 库.该库依赖 Microsoft.Win32 进行注册表查找.

This project again has a dependency on another (external) .NET Standard 2.0 library which has been added through a private Nuget repo. This library depends on Microsoft.Win32 for Registry lookup.

在调试 .Net FW 应用程序时,我们在运行时收到 FileNotFoundException:

When debugging the .Net FW application, we get a FileNotFoundException during runtime:

System.IO.FileNotFoundException:无法加载文件或程序集Microsoft.Win32.Registry,版本=4.1.1.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"或其依赖项之一.系统找不到指定的文件.'

我更改了使用注册表的库并添加了 Microsoft.Win32.Registry 包.再次调试时,错误更改为不同版本:

I changed the library that uses the Registry and added the Microsoft.Win32.Registry package. When debugging again the error then changed to a different version:

无法加载文件或程序集Microsoft.Win32.Registry,版本=4.1.3.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"或其依赖项之一.系统找不到指定的文件.

我们在哪里努力解决这个问题?使用 Win32.Registry 的库中是否有配置错误?还是依赖于它的 .NET Standard 项目?还是在 .NET 4.7 应用程序的顶层?

Where do we put the efforts into fixing this? Is something configured wrong in the library that uses Win32.Registry? Or is it the .NET Standard project depending on it? Or in the top layer in the .NET 4.7 application?

推荐答案

对于找到该线程的任何人,有效的方法是将外部库使用的 win32.registry nuget 包也添加到 .net framework 4.7 项目中.

For anyone finding the thread, what worked was to add the win32.registry nuget package used by the external library to the .net framework 4.7 project as well.

即使认为这感觉远非最佳,但这是在这种情况下唯一有效的方法,而且必须这样做.

Even thought this feels far from optimal, it was the only thing that worked in this case, and it'll have to do.

参考:为什么我的 .NET 框架应用程序寻找错误版本的 .NET 核心/标准平台扩展程序集,我该如何解决?

这篇关于Netstandard 依赖 System.IO.FileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆