In Development
Last Updated: 15 Nov 2024 13:33 by ADMIN
Martin Ivanov
Created on: 15 Nov 2024 13:07
Category: TouchManager
Type: Bug Report
0
TouchManager: FileNotFoundException in resolving System.Windows.Forms assembly in InitializeProperties method after .NET 9 application is published

The exception occurs when publishing .NET 9 application and the "Deployment Mode" in the "Publish profile" is set to "Self-contained".

The exception is not displayed, but instead the application crashes at startup and it seems like it cannot start at all. You can see the error in the Events Viewer tool of the Windows OS, after you navigate to the "Windows Logs-->Application" menu.

This is not reproducible in .NET 8.

The original stacktrace where this was hit is the following:

 

System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
File name: 'System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   at Telerik.Windows.Input.Touch.TouchManager.InitializeProperties()
   at Telerik.Windows.Input.Touch.TouchManager.RemoveTapHoldAndReleaseEventHandler(UIElement element, TouchEventHandler handler)
   at Telerik.Windows.Controls.RadContextMenu.AttachHandler(UIElement element)
   at Telerik.Windows.Controls.RadContextMenu.CreateReferences(UIElement element)

 

To work this around, you can try one of the following ideas:

  • Change the target framework of your project to .NET 8 or earlier.
  • Use the "Framework-dependent" Deployment mode in the Publish profile.
  • Add a reference to the C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\9.0.0\System.Windows.Forms.dll file in your project.


0 comments