Experience in ensuring cross-platform compatibility of a desktop application with a graphical interface based on .NET

Introduction

Today, domestic companies increasingly prefer to switch to alternative operating systems. This trend is due to the fact that many corporations, including Microsoft, have officially suspended support for their products in Russia [9, 10, 11]and from September 2024 they also plan to suspend the provision of cloud services. At the same time, at the moment, domestic developments are distinguished by a high level of security and reliability of systems, confirmed, among other things, by FSTEC certificates. The most popular domestic operating systems (OS) based on the Linux kernel are: Astra Linux, ROSA Linux, ALT Linux and RED OS.

Corporate users most often choose large software products (SP) with a long history of development and proven themselves in practice to solve problems. Writing similar SP from scratch for a new system is much more expensive than adapting them. There are many software products with a graphical interface implemented using the object-oriented C# language on the .Net platform. This is due to the prevalence of the language, its versatility, extensive functionality, as well as relative independence from hardware and a specific OS version.

This article examines the process of ensuring cross-platform software products with a graphical interface on the .Net platform for operation both in the Windows operating system and in the Linux family of operating systems. The basis for the study is the NGT SMART+ software product (Figure 1), which is a convenient and modern tool for automating the processes of monitoring and analyzing the development of oil and gas fields.

Figure 1. NGT SMART+ software product.

Figure 1. NGT SMART+ software product.

Statement of the problem

The NGT SMART+ software product is implemented using the object-oriented C# language on the Microsoft .Net Framework 4.0 platform. The most reliable way to launch the software product on Unix-like systems is to switch to cross-platform development. There is no ready-made solution from the developer of the .Net platform (Microsoft) that would allow porting the software product to Unix-like systems in a short time, with minimal labor costs, while maintaining the ability to compile the code for work under Windows OS.

As part of the study, in order to limit the execution time, it was decided to abandon the complete rewriting of the project. Also, to limit labor costs, the original programming language is preserved with minimal reworking of the source code, support for the .Net platform and the Windows Forms graphical interface (desktop application) is provided.

Thus, the Task is to ensure cross-platformity of the NGT SMART+ software product with a graphical interface on the .Net platform for operation both in the Windows operating system and in Unix-like systems. The study considered the use of such solutions as Wine, Mono, PlayOnLinux and CrossOver.

To solve the problem, the following algorithm was proposed:

  • analysis of existing solutions;

  • study of software that allows you to run applications created for Windows on Unix-like systems;

  • installation of necessary tools and preparation of the execution environment on machines with Unix-like operating systems;

  • conducting testing and eliminating emerging conflicts.

In order to reduce labor intensity, the Astra Linux and RED OS operating systems were selected for testing based on their prevalence among customers and popularity in the Russian market.

Analysis of existing solutions

The analysis showed that cross-platform console applications and libraries can be developed on the .Net platform. However, it is impossible to develop software products with a full-fledged graphical interface. [3]As a result, many authors resort to alternative solutions to the problem through third-party solutions (Wine, Mono and CrossOver).

The most popular tool is Wine software. It is free and open source software that does not have any special hardware requirements. [17]Wine software correctly launches most software products (except special software products) and is aimed mainly at emulating Windows OS to run computer games on Linux OS [5, 15]. Difficulties may arise with reading and writing program files, as well as with the correct display of the interface. [7]. In addition, experiments conducted to launch malicious software revealed security issues when using Wine software. [8, 13, 16].

The next viable software alternative is the Mono software platform. It is less popular, but its advantage is the ability to ensure the operation of the application without any emulation on both Windows and Linux OS. [1]. A performance study measuring the time it takes to run an algorithm found that Mono software is often more efficient than native code. [12].

CrossOver software has a user-friendly graphical interface and clear documentation. This program is commercial, but the trial period allows you to fully evaluate the functionality and capabilities of the product. Among the shortcomings, users note the instability of multimedia applications [14].

The analysis revealed serious shortcomings in existing solutions:

  • there are no descriptions of the software operation using a real example;

  • the difficulties that may be encountered during the work process and the methods for solving them are not recorded;

There is no provision for variability in operating systems, software tools and their versions.

Solutions to the problem

An analysis was conducted in the format of assessing the advantages and disadvantages of previously presented porting tools.

The Mono software platform acts as an implementation of the Microsoft .NET Framework. Important advantages of this tool include binary compatibility, open source code, and free access to the project. At the time of writing, the latest stable version is 6.12.0.

When working with this platform, difficulties arise due to the fact that the Mono platform does not contain the implementation of a number of functions available in .NET. As a result, when porting to Mono, it is necessary to search for alternative solutions and, if available, make changes to the code of the software product. Today, the platform is not widely popular among developers, so the conflicts that arise are poorly studied.

Wine software redirects Windows API calls to the corresponding POSIX calls [6]. This approach provides the ability to minimize memory loss and maintain performance. Wine software allows you to install the necessary libraries and components of the Windows OS [4]. The software is actively being improved and the latest stable version is 9.0. At the same time, Wine software is in demand among both developers and ordinary users. To ensure cross-platform software for correct operation, it is necessary to upgrade its version to .NET 5 and higher.

The free PlayOnLinux program uses all the capabilities of Wine software, since it is its add-on. Thanks to its user-friendly interface, it is suitable for beginners. However, it has significant disadvantages:

  • support is provided for a narrow range of programs,

  • loss of performance (slowdown) is allowed,

  • a small circle of users (rarely mentioned in articles and forums).

CrossOver is focused on running popular Windows office applications and is an analogue of Wine software. The program is easy to install and use. CrossOver is not a free open source solution [2]. The main disadvantage is that the program is limited in access within Russia.

Based on the above analysis, two strategies have been developed for

ensuring cross-platform compatibility of the NGT SMART+ software product with a graphical interface on the .Net platform:

  1. Using PP Mono.

  2. Using Wine software.

In case of an unsuccessful experience with one of the products, it is still possible to use the backup one and simultaneously test two options for solving the given Task.

The first, more priority strategy is to use the Mono software platform, since it supports binary compatibility. The second strategy is to use Wine software, a popular software product with wide functionality. In case of failure of the implementation of these strategies, the solution is to use alternative GUI frameworks (graphical interface tools), which offer a predominantly different approach to the user interface.

The Mono software does not implement some of the functionality, so it must be temporarily removed from the NGT SMART+ software product. To do this, testing is carried out on a Linux distribution directly in Windows using WSL (Windows Subsystem for Linux – a Windows subsystem for running Linux applications). After removing the unsupported functionality, it is necessary to prepare a runtime environment on machines with the Astra Linux operating system and RED OS. The Mono repository is added to the list of sources and the mono-complete package is installed. This package loads the necessary libraries, development tools and runtime environment.

During testing on Unix-like systems, several conflicts were detected. There were problems at the system call level, for the solution of which it was necessary to make changes to the source code of the Mono software. Failures were recorded using modern libraries that the Mono software does not support. The only way out is to find alternative solutions and rewrite the source code of the NGT SMART+ software product. Since this approach is not practical in the long term, it was decided to stop working with the Mono software platform and move on to testing a solution based on the Wine software.

The .Net Framework 4.0 platform on which NGT SMART+ is implemented is not cross-platform and is designed to work only on Windows OS. Therefore, when starting to work with Wine software, it is necessary to upgrade the platform version to .NET 5, then prepare the runtime environment on machines with the selected operating systems. To do this, install the Wine and Winetricks packages (an auxiliary script for configuring Wine), create a new prefix and add the .NET 5 runtime environment.

The software product was successfully launched in the Astra Linux and RED OS operating systems. Testing was carried out on Wine versions 6.23, 8.0.2 and 9.0. During testing, a number of errors were identified and corrected, which are discussed in more detail in the next part of the article. The result of the work done is a script that includes: installing Wine software, changing settings and creating a shortcut. To automatically configure the execution environment, you need to place the script in the internal project folder, run it on behalf of the current user and reboot the computer.

The above two strategies for solving the Problem are presented in Figure 2.

Figure 2. Strategies for solving the problem of ensuring cross-platformity of the NGT SMART+ software product with a graphical interface on the .Net platform

Figure 2. Strategies for solving the problem of ensuring cross-platformity of the NGT SMART+ software product with a graphical interface on the .Net platform

Difficulties identified

During testing of the software product on Unix-like systems using Wine software, the following shortcomings were identified:

– the application's own fonts were missing,

– incorrect graphics rendering was observed,

– during the work process the focus was lost.

When working, there is an obvious discrepancy between the software product interface rendering and the original: the application's own fonts in TFF format are not loaded, there is no anti-aliasing of graphics and fonts. The cause of the problem is the lack of the graphic subsystem library “gdiplus.dll”. In the software product, the TFF font is used to display various states of wells and other objects. To display a well, a system of superimposing two symbols of black and yellow is used. Figure 3 shows a comparison of the well display with and without the library.

Figure 3. Comparison of wells using the “gdiplus.dl” library (a) and without it (b)

Figure 3. Comparison of wells using the library “gdiplus.dl” (a) and without it (b)

The “gdiplus.dll” library provides many features, including the ability to use splines, which allow you to visualize smooth curved lines. “gdiplus.dll” is installed relatively easily using Winetricks. The result of using the library for smoothing graphics is shown in Figure 4.

Figure 4. Comparison of graphics with the gdiplus.dll library (a) and without it (b)

Figure 4. Comparison of graphics with the gdiplus.dll library (a) and without it (b)

Font smoothing is fixed with Winetricks by changing the FontSmooth setting. This setting helps to enable Grayscale font smoothing and RGB and BGR subpixel smoothing.

The next serious drawback in the program operation under Wine is the loss of focus of the software product. This problem manifests itself in the fact that the window becomes inactive. Pressing the buttons does not work the first time (you need to return the focus to the window) and drop-down lists automatically close after a few seconds. Loss of focus in the case of using Wine software is often associated with the appearance of tooltips, since they are displayed as a separate window and intercept the focus. This error is eliminated in the following ways. The first is to disable the UseTakeFocus setting in Winetricks or in the registry editor Regedit. The proposed method is not suitable for all software products – for example, when working in the NGT SMART+ software, uncontrolled movement of focus occurred across the project windows. The second method is to use a virtual desktop, which is connected in the Winecfg settings editor in the graphics section. This method for the NGT SMART+ software led to more serious errors – pop-up windows and prompts were displayed behind the main program window and the visual component of the virtual table did not meet the Customer’s requirements.

This problem was solved for the RED OS operating system using the Openbox window manager: it is enough to add the focus property for the corresponding window to the main configuration file “rc.xml”.

<application class="smartplus.exe" role="normal">
<focus> yes</focus>
</application>

Fixing the problem for the Astra Linux operating system is possible by configuring window settings. It is necessary to change the behavior of windows of the corresponding class, setting that they are always located on top of others.

Conclusion

The presented work on the use of the software product in the Windows operating system and in Unix-like systems is based on the need to ensure the launch of domestic developments in Linux family operating systems that meet the requirements of import substitution and minimize sanctions risks. The entire process of ensuring the cross-platform nature of the software product with a graphical interface on the .Net platform is presented using the example of the “NGT SMART+” project focused on the Windows operating system.

Based on the analysis of existing tools for porting Windows desktop applications to Linux family OS, two strategies have been developed: using the Mono software platform and Wine software. Despite the fact that at first glance the Mono software platform serves as the best solution to the task, since it is an implementation of the Microsoft .NET Framework platform and has bytecode compatibility, in practice many difficulties have arisen associated with the use of modern libraries, without which the implementation of a modern graphical user interface is difficult.

The transition to the second strategy based on Wine software allowed us to successfully complete the task of launching the application under domestic Astra Linux and RED OS operating systems. It is worth considering that when working with Wine software, it is necessary to upgrade the platform version of the NGT SMART+ project to .NET 5. The resulting shortcomings related to interface rendering, font loading, and loss of focus are solved using Winetricks and a window manager. Installing Wine software, correcting the listed shortcomings, and creating a program shortcut are included in the developed script for automatic configuration of the execution environment.

This article does not consider the risks associated with import substitution of Wine software. It is expected that they will be mitigated by using domestic analogues.

List of sources

1. Ageev E.L. Development in C# under Linux. Gagarin Readings 2017: Abstracts of Reports, Moscow, April 5–19, 2017. — Moscow: Moscow Aviation Institute (National Research University), 2017. — P. 665.

2. Beshkov A. Launching Windows applications under Linux using CrossOver Office. System administrator. — 2004. — No. 2(15). — P. 4–13.

3. Gorbunov V. A. Software for the implementation of cross-platform .net applications. International scientific and technical conference of young scientists of BSTU named after V.G. Shukhov: Conference Proceedings, Belgorod, April 30 – 20, 2021. – Belgorod: Belgorod State Technological University named after V.G. Shukhov, 2021. – P. 3539-3542.

4. Demidov N. A., Vygonyailo K. V., Manyaev A. A. Comparative analysis of Wine and PortProton: Cross-platforms in the context of Windows application emulation. Software systems and computational methods. — 2024. — No. 2. — P. 99–118.

5. Komrakov A. A., Ushakova K. O., Isaev V. G. Import substitution of software in the aerospace segment of the defense industry complex. Information Technology Bulletin. – 2019. – No. 4 (22). – P. 71-82.

6. Lunchenkova E. B., Goryacheva N. V. Capabilities of toolkits for developing electronic educational resources used under the Windows operating system on computers running the Astra Linux operating system with the Wine middleware installed on them. The penitentiary system and society: interaction experience: Collection of materials from the IX International scientific and practical conference, Perm, April 6–8, 2022 / Comp. A. I. Sogrina. Volume 1. — Perm: Perm Institute of the Federal Penitentiary Service, 2022. — P. 112–115.

7. Soloviev A. V. Methods for running Windows applications on a computer running Astra Linux. New information technologies in scientific research: Proceedings of the XXVIII All-Russian scientific and technical conference of students, young scientists and specialists, Ryazan State Radio Engineering University named after V.F. Utkin, November 22–24, 2023. — Ryazan: Ryazan State Radio Engineering University named after V.F. Utkin, 2023. — P. 170–171.

8. Uimin A. G., Morozov I. M. Wine safety assessment using the STRIDE methodology: a mathematical model. Modern Science: Current Problems of Theory and Practice. Series: Natural and Technical Sciences. — 2023. — No. 6–2. — P. 164–170.

9. Khvatov A. A., Derevyankin A. Yu. The Impact of Sanctions on the Development of Information Technologies in Russia. Bulletin of Eurasian Science. – 2023. – Vol. 15. – No. s1.

10. Khramtsova S. N. Import substitution in the it sphere. NEW PATH OF THE RUSSIAN ECONOMY: IMPORT SUBSTITUTION, INNOVATION, ECONOMIC SECURITY: collection of articles from the International scientific and practical conference, Voronezh, December 15, 2022. – Ufa: Limited Liability Company “Aeterna”, 2022. – P. 92-101.

11. Shershakov A. D. Implementation of alternative operating systems in the production sphere under sanctions in Russia. Yakovlev readings: Proceedings of the All-Russian scientific and practical conference, St. Petersburg, April 4, 2022. – St. Petersburg: OOO “Skifiya-print”, 2022. – P. 135-137.

12. Blajian, Gregory & Eggen, Roger & Eggen, Maurice & Pitts, Gerald. Mono versus.net: A Comparative Study of Performance for Distributed Processing. Proceedings of the International Conference on Parallel and Distributed Processing Techniques and Applications & Conference on Real‑Time Computing Systems and Applications, PDPTA 2006, Las Vegas, Nevada, USA, June 26–29, 2006, Volume 1, Pages 45–51.

13. Duncan, Rory & Schreuders, Z. Security implications of running windows software on a Linux system using Wine: a malware analysis study. Journal of Computer Virology and Hacking Techniques, 15(1), 2019.

14. Hall Jes. CrossOver Office 5.0. ACM Digital Library. URL: https://dl.acm.org/doi/fullHtml/10.5555/1 152 899.1152917 (accessed: 27.03.2024).

15. LeBlanc Dee-Ann. Get Your Game On. Running Windows Games in Linux. ACM Digital Library. URL: https://dl.acm.org/doi/fullHtml/10.5555/1 118 998.1119013 (access date: 03/27/2024).

16. Septiasari, Rycka & Pramadi, Yoga. A study on windows‑based ransomware implications on linux operating system using compatibility layer wine based on dynamic analysis. IOP Conference Series: Materials Science and Engineering, 2020, 1007, 012 120.

17. Zhao, Huimin. A Design of Information Teaching Platform Based on Linux Operating System. Journal of Physics: Conference Series, 2021, 2138, 012 018.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *