0

I am new and have a little bit knowledge in Linux. That's said, let me summarize my problem. I have a big application which is written in winforms and i want it to run on ubuntu. I used mono but after running mono migration analyzer, P/invoke was not migrated so i used wine to run the application.

With wine, most of the part in the application worked fine but crashes on many occasion and the performance is also slow. I send the message to their forum but it was not resolved as seen here

After wine, i tried to see the possible platform to run the application on ubuntu. One of them to use Avalonia UI for the front end and C# code will be reused. So i created a prototype to see if the application crashes or throw any exception. It shows the DLLNotFoundException which after contacting the AvaloniaUI support point out that dll only worked on windows platform as indicated here

Now i searched out the solution but most of them telling me to use wine or mono, some old solution were telling me to use gcc as indicated here and here but gcc only compile c and C++.

Can someone guide me what to do here.

3
  • What in your application are you prepared to rewrite and what are you looking to achieve and by that i mean do you need a cross platform solution, a ubuntu only solution? What is stopping you rewrtting it in something that works well on ubuntu. Interms of what else runs on ubuntu ignoring wine and mono .net core runs on there but wont be any good for the GUI unless you rewrite it with a web front end and a local server(e.g. Kestrel) running. If you just want it to be in c# and visual studio you can use xamarin but there would be a pretty big rewrite on your hands neither sounds great tbh.
    – Donald
    Commented Dec 30, 2020 at 15:36
  • Dont know too much about avalonia so i cant comment on that.
    – Donald
    Commented Dec 30, 2020 at 15:38
  • I want to rewrite the application on a cross platform and for GUI i use avalonia which uses xaml to design front-end. i created a program in avalonia and GUI is displayed. The problem is with netapi32.dll which don't work on the ubuntu (I am testing it only in ubuntu). In this link you can view the error when running it on ubuntu Commented Dec 30, 2020 at 15:51

1 Answer 1

1

I have looked at screenshot at your comment.

Your problem does not relate Avalonia, because Avalonia is UI framework, and you are invoking Networking routines, such as NetApiBufferFree(IntPtr buf).

I suppose, that you may need to look answer for a question "How to list all computers in local network in cross-platform way".

I think that you may need to split your solution to separate projects:

First one is for interface, its target is an application,

Second one should contain your logic for Windows, with code like this: https://morgantechspace.com/2014/04/get-list-of-network-computer-names-in-c-sharp.html#Get-Network-PC-Names ;

Third one may contain your calls to Linux-specific routines; There you should check how to call Linux system routines on C#. There is less info on this subject, but I'd start here: Get list of devices on LAN in C .

A first project should depend on second and third.

Obviously, your solution should target .NET Core; or Mono.

2
  • The problem is i have many other dll which are working in my project. I choose to work with netapi32.dll randomly. I have same logic for windows which are shared by you. The link you provide is for C and i want to work on C# In summarize, is there any option available to use netpi32 or anyother dll in linux. My solution is built in .net core and i installed it on linux as well. Commented Dec 31, 2020 at 8:07
  • @JunaidAmjad Ask a new question - how to use pinvoke on Linux. You need to call system routines of Linux to solve this task. And system routines are called on C. You cannot use netapi32 on linux natively, it is native networking library of Windows
    – Ivan P.
    Commented Dec 31, 2020 at 19:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.