Can I use .NET framework DLL in .NET core?

Prabs 1 Reputation point
2021-03-30T06:39:03.983+00:00

Hello All,
I have an .Net Core console application. Can I use .NET framework DLL in .NET core?
Please help me on this

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
7,022 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: The period of time during which a program is being executed in a computer.
960 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 66,071 Reputation points
    2021-03-30T06:47:37.193+00:00

    Normally, no.
    But there is the Windows Compatibility Pack for .NET Core


  2. Karen Payne MVP 29,236 Reputation points MVP
    2021-03-30T13:22:09.037+00:00

    You should consider taking the .NET Framework code and migrating to .NET Core. Benefits include faster execution of code when moving to .NET Core along with having the ability to use new features in C#8 and C#9.

    The most challenging part of going to .NET Core is finding certain references such as in .NET Framework, in a class project if a reference for System.Windows.Forms was needed it's easy to do while in .NET Core one needs to find the reference by browsing to

    C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\5.0.0\ref\net5.0

    Then selecting System.Windows.Forms.dll

    Or add commonly used references to the Object browser which also allows you to add a reference to the current project with a single click.

    82773-f1.png

    Cleaner code can be written e.g.

    public static void ConventionalExample()  
    {  
        using (var cn = new SqlConnection(ConnectionString))  
        {  
            cn.Open();  
        }  
    }  
      
    public static void CoreExample()  
    {  
        using var cn = new SqlConnection(ConnectionString);  
        cn.Open();  
    }  
      
    

    In closing, best to use the older code as a bridge which gives time to write the .NET Core class project.

    No comments