简体   繁体   English

从.NET Framework传统项目引用.NET Standard csproj项目

[英]Referencing .NET Standard csproj project from .NET Framework traditional project

I have a library written against .NET Standard 1.3 which should be compatible with the .NET Framework 4.6.1 runtime. 我有一个针对.NET Standard 1.3编写的库,它应该与.NET Framework 4.6.1运行时兼容。 The library uses the new csproj and works fine when referenced by .NET Core projects. 该库使用新的csproj,并且在.NET Core项目引用时工作正常。

I also have a WPF project on a traditional csproj which should be able to use this library. 我还在传统的csproj上有一个WPF项目,它应该可以使用这个库。 In Visual Studio 2017 I managed to reference the .NET Standard library and it compiles without errors. Visual Studio 2017中,我设法引用了.NET标准库,它编译时没有错误。

At runtime, it tries to load assemblies which are dependencies of the .NET Standard project and it fails with assembly not found exceptions. 在运行时,它尝试加载与.NET Standard项目的依赖关系的程序集,并且在程序 assembly not found异常时失败。 And I can see that my output folder doesn't have any of the dependencies indeed. 我可以看到我的输出文件夹确实没有任何依赖项。

Is there a way to reference my library in such a way all the required dependencies are copied to the output folder (or an equivalent solution to make the WPF project run fine)? 有没有办法以这种方式引用我的库所有必需的依赖项被复制到输出文件夹(或一个等效的解决方案,使WPF项目运行正常)?

Note: If I reference manually one by one all the missing dependencies and use runtime assembly version binding I can make it run, but I shouldn't really do this when referencing a project. 注意:如果我逐个手动引用所有缺少的依赖项并使用运行时程序集版本绑定我可以使它运行,但在引用项目时我不应该这样做。

This is the full project page: https://github.com/UnoSD/PasswordManager 这是完整的项目页面: https //github.com/UnoSD/PasswordManager

.NET Standard csproj .NET标准csproj

WPF package.config WPF package.config

WPF csproj WPF csproj

It currently is a Roslyn problem: GitHub issue 它目前是一个Roslyn问题: GitHub问题

You have to specify compiler output for .NET 4.6.1 您必须为.NET 4.6.1指定编译器输出

Put line like below into your csproj in your .NET Standard library project. 将下面的行放入.NET标准库项目的csproj中。

<TargetFrameworks>netstandard1.4;net461</TargetFrameworks>

(that should go instead <TargetFramework>netstandard1.4</TargetFramework> ) (应该改为<TargetFramework>netstandard1.4</TargetFramework>

Build will produce binaries both for .NET 4.6.1 and .NET Core runtime compatible with NET Standard 1.4. Build将为.NET 4.6.1和与.NET Standard 1.4兼容的.NET Core运行时生成二进制文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .Net Framework 4.7.2 引用.Net Standard 2.0 项目 - .Net Framework 4.7.2 Referencing .Net Standard 2.0 project 从 .NET Standard 项目的 csproj 获取所有依赖项的列表 - Getting a list of all dependencies from a .NET Standard project's csproj 从 .Net 标准类库引用 .Net Core 3.1 项目 - Referencing a .Net Core 3.1 project from a .Net Standard Class Library 引用.NET Standard项目时,NET Framework项目无法加载程序集 - NET Framework project can't load assembly when referencing .NET Standard project 引用.NET Core XUnit项目中的标准dll - Referencing standard dlls from a .NET Core XUnit project 面向 .NET Standard 并使用新的 csproj 格式的 VSIX 风味项目 - VSIX flavored project that targets .NET Standard and uses the new csproj format .Net Framework dll无法处理.Net标准项目 - .Net Framework dll not working on .Net Standard project 从CoCoa应用程序引用.NET Framework 4.5类库项目 - Referencing .NET Framework 4.5 Class Library project from CoCoa application 引用生成EF Core dbcontext的.NET Standard 2.0项目的.NET Framework MVC项目。 为什么不起作用? - .NET Framework MVC project referencing a .NET Standard 2.0 project that generates a EF Core dbcontext. Why doesnt it work? 从Asp.Net 4.7项目引用.Net Standard 2.0库时出错 - Error when referencing .Net Standard 2.0 library from Asp.Net 4.7 project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM