Could not load file or assembly 'System.Windows.Forms' in Net6

Stimulsoft Reports.NET discussion
Post Reply
Milton Guevara
Posts: 53
Joined: Thu Aug 21, 2008 9:28 pm
Location: Peru

Could not load file or assembly 'System.Windows.Forms' in Net6

Post by Milton Guevara »

Hi, I'm using Net 6, with a library-type project to generate a report that exports to PDF, but when executing I get the following error: "Could not load file or assembly 'System.Windows.Forms, Version=4.0. 0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified."
The libraries that I have installed are from Stimulsoft and are ".NETCoreApp3.1", which are supposed to be compatible with Net6
please your support

Regards
Milton
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: Could not load file or assembly 'System.Windows.Forms' in Net6

Post by Max Shamanov »

Hello,

You should add a reference to the assembly, by using the following code:

Code: Select all

using System.Windows.Forms;
Also please check our samples:
https://github.com/stimulsoft/Samples-N ... rms-CSharp

Thank you.
Milton Guevara
Posts: 53
Joined: Thu Aug 21, 2008 9:28 pm
Location: Peru

Re: Could not load file or assembly 'System.Windows.Forms' in Net6

Post by Milton Guevara »

Hello Max
It is not a "Windows Form" project, I am working on a "Library" type project where Forms is not referenced.
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Could not load file or assembly 'System.Windows.Forms' in Net6

Post by Lech Kulikowski »

Hello,

You can remove that assembly from the (Referenced Assemblies) property of the report.

Thank you.
Milton Guevara
Posts: 53
Joined: Thu Aug 21, 2008 9:28 pm
Location: Peru

Re: Could not load file or assembly 'System.Windows.Forms' in Net6

Post by Milton Guevara »

Hello

The error occurs in the line where the "StiReport" is instantiated, not in the load of the report.

StiReport report = new StiReport();

In which report should I remove the reference?
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Could not load file or assembly 'System.Windows.Forms' in Net6

Post by Lech Kulikowski »

Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
Milton Guevara
Posts: 53
Joined: Thu Aug 21, 2008 9:28 pm
Location: Peru

Re: Could not load file or assembly 'System.Windows.Forms' in Net6

Post by Milton Guevara »

It was fixed by replacing "Stimulsoft.Reports.Engine" with "Stimulsoft.Reports.Enginee.NetCore".
Thanks for the support.
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: Could not load file or assembly 'System.Windows.Forms' in Net6

Post by Max Shamanov »

Hello,

You are welcome!
Post Reply