top of page

WinForms in einer 64-Bit Welt / WinForms in a 64-Bit world

(alle Versionen/all versions)

Freitag, 1. März 2024

Deutsch

Umstellung auf .NET 8+

Verwendung von "AnyCPU"

32-Bit-Komponenten modernisieren


English

Move to .NET 8+

Use AnyCPU

Modernizing the 32-Bit components


Links


Deutsch

Microsoft-Mitarbeiter Klaus Löffelmann gibt in einem Blog-Eintrag diverse Hinweise zu dem aktuellen Stand von Microsofts in die Jahre gekommenen UI/UX-Technologie "Windows Forms", inklusive Ausblick in die Zukunft.

Windows-Forms-Entwickler sind in der Praxis sehr häufigt für die Wartung von Software verantwortlich, die für Endkunden oft geschäftskritisch ist.

Windows-Forms findet sich mehr als ein Jahrzehnt in vielen Projekten der Verwendung.

Entwickler stoßen dabei oft an 32-Bit-Grenzen.

Schon die Umstellung von Microsofts Tools rund um Windows-Forms von 32-Bit auf 64-Bit in Visual Studio 2022 führte zu diversen Problemen.

Klaus Löffelmann, Senior Software Engineer .NET/Desktop UI/Windows Forms bei Microsoft sagt dazu:

Wir sind uns bewusst, dass diese Änderungen zu einigen Verzögerungen bei der Entwicklung führen, und wir möchten diese Probleme klären, indem wir auf bereits verfügbare Umgehungslösungen und unsere zusätzlichen Pläne zur Lösung dieser Probleme hinweisen.

Umstellung auf .NET 8+

Die zukunftsorientierteste Option wäre jedoch, auf .NET 8 oder höher zu aktualisieren.

Die .NET 8+ Umgebung ist die Zukunft der (nicht nur) WinForms-Anwendungsentwicklung und bietet den umfassendsten Support, insbesondere wenn es um Drittanbietersteuerelement-Anbieter geht.

Mit .NET 8+ bleiben Sie nicht nur auf dem neuesten Stand - Sie bleiben voraus, um sicherzustellen, dass Ihre Anwendungen für alles bereit sind, was die Zukunft bringt.


Verwendung von "AnyCPU"

Zunächst sollten Sie für die Designzeit alles auf 'AnyCPU' umstellen.

Die 'AnyCPU'-Kompilierungsoption in Visual Studio bietet eine vielseitige Lösung für das Problem mit den 32-Bit-Komponenten in Ihrem WinForms-Projekt.

Wenn Ihr Projekt auf 'AnyCPU' eingestellt ist, wird Visual Studio Ihre Anwendung so kompilieren, dass sie auf sowohl 32-Bit- als auch 64-Bit-Plattformen ausgeführt werden kann.

Im Kontext der Designzeit bedeutet diese Flexibilität, dass Ihr Prozess auf einem 64-Bit-System als 64-Bit ausgeführt werden kann, sodass Sie die Vorteile von 64-Bit-Visual Studio voll ausnutzen können, wie z.B. verbesserte Speichernutzung und schnellere Operationen.

In vielen Fällen funktioniert dies gut für Projekte, die 32-Bit-Runtime-Komponenten erfordern.

Wenn es um die Laufzeit nach einer Designsession geht, wird die Einstellung 'Bevorzuge 32-Bit' ('Prefer 32-bit') entscheidend für die Kompatibilität mit älteren 32-Bit-Komponenten oder -Bibliotheken.

Durch Aktivieren dieser Einstellung weisen Sie dem Common Language Runtime (CLR) an, Ihre mit 'AnyCPU' kompilierte Anwendung in einem 32-Bit-Prozess auszuführen, selbst auf einem 64-Bit-System.

Dies bietet eine Umgebung, in der Ihre 32-Bit-Komponenten wie erwartet funktionieren und somit den reibungslosen Betrieb Ihrer Anwendung gewährleisten. Obwohl dieser Ansatz einige der 32-Bit-Einschränkungen mit sich bringt, wie z.B. einen kleineren Speicherplatz, bietet er eine effektive Lösung zum Ausgleich zwischen der Notwendigkeit von 64-Bit-Designzeitfähigkeiten und den Anforderungen von 32-Bit-Komponenten zur Laufzeit.


32-Bit-Komponenten modernisieren

Wenn die erste Option aufgrund der Architektur der 32-Bit-Komponente nicht durchführbar ist, könnten Sie in Betracht ziehen, von den 32-Bit-Komponenten wegzumigrieren.

Obwohl dies möglicherweise eine anfängliche Investition von Zeit und Ressourcen erfordert, sind die langfristigen Vorteile signifikant.

Der Übergang zu einer 64-Bit-Umgebung bietet nicht nur bessere Leistung, sondern auch erhöhte Sicherheit.

Darüber hinaus bereitet es Ihre Anwendungen auf zukünftige Updates und Fortschritte vor und gewährleistet so ihre Langlebigkeit.



English

Microsoft employee Klaus Loeffelmann provides various insights into the current state of Microsoft's aging UI/UX technology "Windows Forms" in a blog post, including a glimpse into the future.

In practice, Windows Forms developers are often responsible for maintaining software that is often critical for end customers.

Windows Forms have been in use for more than a decade. Developers often encounter 32-bit limitations. Even the transition of Microsoft's tools surrounding Windows Forms from 32-bit to 64-bit in Visual Studio 2022 led to various issues.

Basically, Klaus Loeffelmann, Senior Software Engineer .NET/Desktop UI/Windows Forms at Microsoft, says:

We are aware that these changes are causing some speed bumps along your development journey, and we want to clarify these issues by pointing out workarounds already available and our additional plans to address them.

Move to .NET 8+

The most forward-thinking option, though, would be to upgrade to .NET 8 or higher.

The .NET 8+ environment is the future of (not only) WinForms Application development and provides the most robust support, especially when it comes to third-party control vendors.

With .NET 8+, you’re not just keeping up with the times – you’re staying ahead, ensuring that your applications are ready for whatever the future brings.


Use AnyCPU

Firstly, for the design time, switch everything to build with ‘AnyCPU’.

The ‘AnyCPU’ compile option in Visual Studio offers a versatile solution for addressing the 32-bit component issue in your WinForms project.

When your project is set to ‘AnyCPU’, Visual Studio will compile your application in such a way that it can run on both 32-bit and 64-bit platforms.

In the context of design time, this flexibility means your process can run as 64-bit on a 64-bit system, allowing you to take full advantage of the benefits of 64-bit Visual Studio, such as improved memory utilization and faster operations.

In many cases, this work quite well for projects, which require 32-Bit-runtime components.

When it comes to runtime after a design session has finished, the ‘Prefer 32-bit’ project setting becomes key for compatibility with older 32-bit components or libraries. By enabling this setting, you’re instructing the Common Language Runtime (CLR) to run your ‘AnyCPU’ compiled application in a 32-bit process, even on a 64-bit system.

This provides an environment where your 32-bit components function as expected, thereby maintaining the smooth operation of your application.

While this approach does impose some of the 32-bit limitations, such as a smaller memory space, it offers an effective solution for balancing between the need for 64-bit design time capabilities and the requirements of 32-bit components at runtime.


Modernizing the 32-Bit components

If the first option is not feasible due to the architecture of the 32-bit component, you might consider migrating away from the 32-bit components.

While this may require an initial investment of time and resources, the benefits you stand to gain in the long run are significant.

Transitioning to a 64-bit environment offers not only better performance but also enhanced security.

Moreover, it prepares your applications for future updates and advancements, thus ensuring their longevity.


Links


Original post:



bottom of page