.Net Core : back compatibility problem when loading a legacy .Net 4.7.2 DLL using System.Console.Write() (missing method)

Pierre Chatelier 81 Reputation points
2020-11-19T10:40:45.697+00:00

I have a .Net 5.0 C# wrapper that dynamically loads a legacy C++/CLI .NET 4.7.2 assembly
Loading is successful, but I cannot run the code : an exception is raised about a missing System.Console.Write() implementation

This is definitely a .Net 5.0 problem, since if the wrapper is a .NET 4.7.2 assembly, there is no problem at all.

I have attached a minimal project to reproduce TestNetCoreBackCompatibility.zip

.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,109 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jerry Cai-MSFT 981 Reputation points
    2020-11-26T08:20:23.923+00:00

    Hi,PierreChatelier

    I noticed after updating a .NET Core 3.1 app to .NET 5.0, the default build output subfolder changes from "netcoreapp3.1" to "net5.0-windows".

    And In your code is <TargetFramework>net5.0-windows7.0</TargetFramework>

    You can try to check this link, hope this can help you:

    https://stackoverflow.com/questions/64807912/can-a-net-core-5-0-assembly-use-a-net-framework-4-8-targeted-assembly

    Best Regards,

    Jerry Cai


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.