<tfoot id='MjxTx'></tfoot>

      <bdo id='MjxTx'></bdo><ul id='MjxTx'></ul>

    <small id='MjxTx'></small><noframes id='MjxTx'>

      <legend id='MjxTx'><style id='MjxTx'><dir id='MjxTx'><q id='MjxTx'></q></dir></style></legend>
    1. <i id='MjxTx'><tr id='MjxTx'><dt id='MjxTx'><q id='MjxTx'><span id='MjxTx'><b id='MjxTx'><form id='MjxTx'><ins id='MjxTx'></ins><ul id='MjxTx'></ul><sub id='MjxTx'></sub></form><legend id='MjxTx'></legend><bdo id='MjxTx'><pre id='MjxTx'><center id='MjxTx'></center></pre></bdo></b><th id='MjxTx'></th></span></q></dt></tr></i><div id='MjxTx'><tfoot id='MjxTx'></tfoot><dl id='MjxTx'><fieldset id='MjxTx'></fieldset></dl></div>
    2. 将 .net 核心与旧版 .net 框架 dll 一起使用

      时间:2023-05-21
      • <bdo id='Mycmd'></bdo><ul id='Mycmd'></ul>

      • <tfoot id='Mycmd'></tfoot>

        <small id='Mycmd'></small><noframes id='Mycmd'>

      • <legend id='Mycmd'><style id='Mycmd'><dir id='Mycmd'><q id='Mycmd'></q></dir></style></legend>
          • <i id='Mycmd'><tr id='Mycmd'><dt id='Mycmd'><q id='Mycmd'><span id='Mycmd'><b id='Mycmd'><form id='Mycmd'><ins id='Mycmd'></ins><ul id='Mycmd'></ul><sub id='Mycmd'></sub></form><legend id='Mycmd'></legend><bdo id='Mycmd'><pre id='Mycmd'><center id='Mycmd'></center></pre></bdo></b><th id='Mycmd'></th></span></q></dt></tr></i><div id='Mycmd'><tfoot id='Mycmd'></tfoot><dl id='Mycmd'><fieldset id='Mycmd'></fieldset></dl></div>

              <tbody id='Mycmd'></tbody>

                本文介绍了将 .net 核心与旧版 .net 框架 dll 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我可以将 .net 核心与旧版 .net 框架 dll 一起使用吗?答案似乎是否定的……但我只能找到引用 project.json 的资源,该资源已不存在.

                Can I use .net core with legacy .net framework dlls? The answer seems to be no... but I can only find resources referring to project.json, which doesn't exist anymore.

                我创建了一个新的 .net 核心库并尝试引用一个旧的 .net 框架 DLL.当我尝试调用 DLL 时,vs2017 抱怨我没有正在寻找的 Stream 对象.

                I created a new .net core library and tried to reference a legacy .net framework DLL. When I tried to call into the DLL, vs2017 complained that I didn't have the Stream object is was looking for.

                它建议我引用 mscorlib.dll 或安装 Nuget 包.

                It suggested I reference either mscorlib.dll or installa Nuget package.

                快速帮助未能引用 mscorlib.dll.如果我手动引用它,我会收到以下错误:

                The quick help failed to reference mscorlib.dll. If I manually referenced it, I get the following error:

                TargetFrameworkAttribute"类型存在于mscorlib"中,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089' 和'System.Runtime,版本=4.1.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a' C:Users...AppDataLocalTemp.NETCoreApp,Version=v1.1.AssemblyAttributes.cs

                The type 'TargetFrameworkAttribute' exists in both 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' C:Users...AppDataLocalTemp.NETCoreApp,Version=v1.1.AssemblyAttributes.cs

                NuGet 包是 Microsoft.NETFx2.0.快速帮助无法安装它.如果我从命令行运行它:

                The NuGet package is Microsoft.NETFx2.0. The quick help fails to install it. If I run it from the command line:

                > PM> install-package microsoft.netfx20   GET
                > https://api.nuget.org/v3/registration2-gz/microsoft.netfx20/index.json
                > OK
                > https://api.nuget.org/v3/registration2-gz/microsoft.netfx20/index.json
                > 46ms Restoring packages for ... Install-Package : Package
                > Microsoft.NetFX20 1.0.3 is not compatible with netcoreapp1.1
                > (.NETCoreApp,Version=v1.1). Package Microsoft.NetFX20 1.0.3 supports:
                > net20 (.NETFramework,Version=v2.0)At line:1 char:1
                > + install-package microsoft.netfx20
                > + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                >     + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
                >     + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
                > Install-Package : One or more packages are incompatible with
                > .NETCoreApp,Version=v1.1.At line:1 char:1
                > + install-package microsoft.netfx20
                > + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                >     + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
                >     + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
                > Install-Package : Package restore failed. Rolling back package changes
                > for .At line:1 char:1
                > + install-package microsoft.netfx20
                > + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                >     + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
                >     + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
                > Time Elapsed: 00:00:00.8035644
                

                推荐答案

                困难的话题.通常 .NET Framework 和 .NET Core 是不兼容的.它们针对的是一组不同的程序集(mscorlib 与 System.Runtime),这会导致不兼容,因为类型的所有用法都以该类型来自的程序集为前缀.

                Difficult topic. Generally .NET Framework and .NET Core are incompatible. They target a different set of assemblies (mscorlib vs. System.Runtime) which causes incompatibilities since all usages of types are prefixed with the assembly the type is from.

                从 .NET Core 2(当前为预览版)开始,您可以通过不可见的兼容性填充程序引用 .NET Framework 程序集.这允许您引用程序集并成功编译.

                Starting with .NET Core 2 (currently in preview), you can reference .NET Framework assemblies through an invisible compatibility shim. This allows you to reference the assembly and compile successfully.

                它不能保证应用程序会成功运行,因为 .NET Core 不提供 .NET Framework 的所有 API.如果是这种情况,您将在运行时收到 PlatformNotSupportedExceptionMissingTypeException 和朋友.

                It doesn't guarantee though that the application will run successfully, since .NET Core doesn't provide all the APIs from .NET Framework. You'll get PlatformNotSupportedException or MissingTypeException and friends at runtime if that's the case.

                这篇关于将 .net 核心与旧版 .net 框架 dll 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:将 Visual Studio 2017 与 .Net Core SDK 3.0 一起使用 下一篇:如何将 Wpf 项目迁移到新的 VS2017 格式

                相关文章

                <small id='AUKaQ'></small><noframes id='AUKaQ'>

                <i id='AUKaQ'><tr id='AUKaQ'><dt id='AUKaQ'><q id='AUKaQ'><span id='AUKaQ'><b id='AUKaQ'><form id='AUKaQ'><ins id='AUKaQ'></ins><ul id='AUKaQ'></ul><sub id='AUKaQ'></sub></form><legend id='AUKaQ'></legend><bdo id='AUKaQ'><pre id='AUKaQ'><center id='AUKaQ'></center></pre></bdo></b><th id='AUKaQ'></th></span></q></dt></tr></i><div id='AUKaQ'><tfoot id='AUKaQ'></tfoot><dl id='AUKaQ'><fieldset id='AUKaQ'></fieldset></dl></div>

                1. <legend id='AUKaQ'><style id='AUKaQ'><dir id='AUKaQ'><q id='AUKaQ'></q></dir></style></legend>

                    • <bdo id='AUKaQ'></bdo><ul id='AUKaQ'></ul>
                  1. <tfoot id='AUKaQ'></tfoot>