Completed
Last Updated: 16 Dec 2024 11:56 by ADMIN
Release 2024.4.1213
Martin Ivanov
Created on: 15 Nov 2024 13:07
Category: TouchManager
Type: Bug Report
2
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.


2 comments
ADMIN
Martin Ivanov
Posted on: 16 Dec 2024 11:56

Hello Martin,

Yes, you should be able to add the UseWindowsForms in your application, instead of adding the System.Windows.Forms.dll manually. However, keep in mind in some specific cases this may lead to ambiguous reference errors.

Also, note that this is already fixed and available in the latest release (released today).

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Martin
Posted on: 16 Dec 2024 11:27

In my opnion you can simply use 

<UseWindowsForms>true</UeWindowsForms>

in your project, right?