How to use .net framework dll in .net core

T.Zacks 3,986 Reputation points
2022-03-09T09:43:17.937+00:00

1) I have few dll which has been developed using .net framework version 4.5.2 and VS2013 those dll used in winform application .net version 4.5.2. now developing a new winform application where i will use .net core 6 and VS 2022.

please guide me all how could i make those dll compatible for .net core 6 winform project?

2) another question is that we heard that .net core application run on linux & Mac OS. does it mean that if i develop a winform application using .net core 6 then does it run on linux & macOS?

3) we used a popular library called MoreLINQ for our winform application. if we are switching to .net core based winform application then can we use this library in .net core. please see this url https://nugetmusthaves.com/package/MoreLinq.Core and guide us.

thanks

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.
10,484 questions
{count} votes

Accepted answer
  1. Karen Payne MVP 35,286 Reputation points
    2022-03-09T11:15:03.043+00:00
    1. For your DLL's, you will need to create .NET Core projects and copy code from the old projects into the new .NET Core projects. Frameworks before .NET Core are not compatible with .NET Core.
    2. No you can not directly use Windows code under linux and IOS as what is in Windows is not in the other two and vis-versa. See Cross-platform mobile development in Visual Studio
    3. Yes you can use MoreLinq under .NET Core projects. Also, there may be improvements in .NET Core 6 that you may not need MoreLinq for or there may be methods that collide between MoreLinq and .NET Core 6.
    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 59,051 Reputation points
    2022-03-11T16:46:15.893+00:00

    while .net core allows creating apps that run on windows, linux and macOS. you must use libraries that run the selected platforms.

    in your case WinForms is a windows only library, so an application using it will only run on windows. It the same on MacOs, if you use UIKit for the UI, the app will only run on MacOs (though you can male a general to run on MacOs and IOS).

    to make cross platform apps, use a web technology like asp.net of the new cross platform Maui UI.

    1 person found this answer helpful.
    0 comments No comments

  2. Julian Tucker 16 Reputation points
    2022-09-05T11:15:29.683+00:00

    If I may add a comment here. We wanted to use a whole load of complex code written over many years in .Net Framework, but have a .Net Core front end that would allow for future proofing the look and feel of the product and maybe now we could even update it to use Maui, but we won't have yet updated (had time to update) the .Net Framework 4.8 code.

    I don't know if anyone might find it useful, but what we have done is this:

    1. Create .Net Core projects (front end .Net Core WinForms in our case) and associated DLL projects containing most of the functionality (allowing us to change WinForms for Maui for instance)
    2. Create a new .Net Framework project (a simple EXE with a hidden interface running in the background at the same time as your main .Net Core interface), containing references to old .Net Framework DLLs that would take too long at this point in time to update and test.
    3. Create a .Net Standard DLL that both projects can reference, this being a communication DLL to allow simple messages (ints/strings etc.) to be sent over Pipes (enum defined here too for the message type, and consider using threads for no blocking).

    Voila! You can now use your old Framework DLLs via the quick Pipe messaging DLL. You just set up the code once to handle the communication so that you can do a standard call, and the data is returned to a standard place. Use of Delegated Callbacks are handy to get data back to the higher level interface places.

    Like I say, this is not for everyone, but once it's set up it just works. It's all standard tested technology. We just simply don't have the time at the moment to update and test this quite complex .Net Framework code. This was relatively quick to set up.

    1 person found this answer helpful.