简体   繁体   English

可以从 .net 核心应用程序引用“传统”(旧).net 库

[英]Possibility to reference "traditional" (old) .net libraries from .net core applications

There are a bit confusing information about the backward referencing possibility from .net core applications (eg ASP.Net Core) to the commonly used .net framework libraries.关于从 .net 核心应用程序(例如 ASP.Net 核心)到常用 .net 框架库的向后引用可能性的信息有点令人困惑。 I got the following impression now:我现在有以下印象:

  1. If you are using "netcoreapp1.0", then you cannot reference an ordinary library at all.如果您使用的是“netcoreapp1.0”,那么您根本无法引用普通库。
  2. If you are using eg "net451", then you can reference it, but you have to wrap it first in a nuget package with corresponding tag.如果您正在使用例如“net451”,那么您可以引用它,但您必须先将其包装在具有相应标记的 nuget 包中。

Does this sound correct?这听起来正确吗?

PS I was thinking that perhaps in case 1 decompiling to IL and recompiling back as "netcoreapp1.0" or "netstandard1.6" or some other voodoo can help? PS 我在想,如果 1 反编译为 IL 并重新编译为“netcoreapp1.0”或“netstandard1.6”或其他一些伏都教可能会有所帮助?

PPS As mentioned in comments it's possible to reference ordinary class library project that can in turn reference the library, but that will mean you have to wrap everything that is in the library, so depends a lot if this can be used. PPS 正如评论中提到的,可以引用普通的类库项目,然后可以引用该库,但这意味着您必须包装库中的所有内容,因此是否可以使用这在很大程度上取决于。

For the moment this is not possible.目前这是不可能的。

You have 3 options:您有 3 个选择:

  1. attempt to convert your old project into a portable class library (PCL), which can then be referenced by your .net core app.尝试将您的旧项目转换为可移植类库 (PCL),然后您的 .net 核心应用程序可以引用它。
  2. wrap your project into a nuget package (you already mentioned that)将您的项目包装到一个 nuget 包中(您已经提到过)
  3. Add the project as a class library (mentioned in the comments), but according to that SO answer and that GitHub thread it does not seem easy to make it work.将项目添加为类库(在评论中提到),但根据那个 SO 答案那个 GitHub 线程,让它工作似乎并不容易。

EDIT on 20-03-2017 : Just came across this post : It seems now possible to have your .NET Core app target .NET 4.6 by changing the .csproj, UNTESTED (yet) 2017 年 3 月 20 日编辑:刚刚看到这篇文章:现在似乎可以通过更改 .csproj 来让您的 .NET Core 应用程序面向 .NET 4.6,但尚未测试

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

to

  <PropertyGroup>
    <TargetFramework>net46</TargetFramework>
  </PropertyGroup>

then dotnet restore followed by dotnet run然后dotnet restore然后是dotnet run

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM