# question

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

Hello All,
I have an .Net Core console application. Can I use .NET framework DLL in .NET core?

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Vote"

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

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I tried now.it is working. I have created some sample .Net framework dll and added into .Net Core project.

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

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.

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.

f1.png (21.0 KiB)

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.