System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Stimulsoft Ultimate discussion
User avatar
Woodcutter
Posts: 56
Joined: Wed Mar 01, 2017 2:17 am

System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Woodcutter »

Hi
When I use below in my Web API with .NET8 .

Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();

The error happened:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 系统找不到指定的文件。 File name: 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' at Stimulsoft.Report.StiReport..ctor() at OrBitCoreService.CLRService.CLR_MRZPrint(String& ReturnMessage, String SQLString, String MRZFile, String PrinterOrFile, Int32 ImageResolution) in D:\OrBitCoreService\CLRService.cs:line 3239

but Webservice with .NET Framework works OK

Anybody knows the reason?

Thanks very much.
Lech Kulikowski
Posts: 6291
Joined: Tue Mar 20, 2018 5:34 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Lech Kulikowski »

Hello,

You should use the Stimulsoft.Reports.Engine.NetCore package instead of the Stimulsoft.Reports.Engine.

Thank you.
User avatar
Woodcutter
Posts: 56
Joined: Wed Mar 01, 2017 2:17 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Woodcutter »

Lech Kulikowski wrote: Mon Apr 15, 2024 12:28 pm Hello,

You should use the Stimulsoft.Reports.Engine.NetCore package instead of the Stimulsoft.Reports.Engine.

Thank you.
Hi Lech

The Stimulsoft.Reports.Engine.NetCore works OK ,but the new error happened.

Code as below:

Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
report.Load(@"d:\abc.mrt");
report.RegData(JsonDS);
report.Render();
System.Drawing.Printing.PrinterSettings printer = new System.Drawing.Printing.PrinterSettings();
printer.PrinterName = "HP Printer"
report.Print(false, printer);

System.Exception:
Printing does not work with a graphics engine based on ImageSharp. Please switch Stimulsoft.Drawing.Graphics.GraphicsEngine to Gdi. at Stimulsoft.Report.Print.StiPrintProvider.Print(StiReport report, Boolean showPrintDialog, Int32 fromPage, Int32 toPage, Int16 copies, PrinterSettings printerSettings)

Thanks for you help

Henry
Lech Kulikowski
Posts: 6291
Joined: Tue Mar 20, 2018 5:34 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Lech Kulikowski »

Hello,

Please set the Stimulsoft.Drawing.Graphics.GraphicsEngine to Gdi.

Thank you.
User avatar
Woodcutter
Posts: 56
Joined: Wed Mar 01, 2017 2:17 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Woodcutter »

Hey Lech

When:
Stimulsoft.Drawing.Graphics.GraphicsEngine = Stimulsoft.Drawing.GraphicsEngine.Gdi;

Then:

System.NullReferenceException: Object reference not set to an instance of an object. at Stimulsoft.Drawing.Font.get_Size() at Stimulsoft.Report.Components.StiWatermark.ShouldSerializeFont() at Stimulsoft.Report.Components.StiWatermark.get_IsDefault() at Stimulsoft.Base.Serializing.StiSerializing.IsDefaultValue(Object valueObject, PropertyDescriptor prop) at Stimulsoft.Base.Serializing.StiSerializing.SerializeObject(Object obj, StiSerializeTypes serializeType) at Stimulsoft.Base.Serializing.StiSerializing.SerializeList(StiPropertyInfoCollection props, Object list, StiSerializeTypes serializeType) at Stimulsoft.Base.Serializing.StiSerializing.SerializeObject(Object obj, StiSerializeTypes serializeType) at Stimulsoft.Base.Serializing.StiSerializing.Serialize(Object obj, StiSerializeTypes serializeType) at Stimulsoft.Report.CodeDom.StiCodeDomSerializator.Serialize(StiReport report, String name, StiLanguage language, Boolean serializeData, Boolean saveForInheritedReports, Object standaloneReportType) at Stimulsoft.Report.CodeDom.StiCodeDomSerializator.Serialize(StiReport report, String name, StiLanguage language, Object standaloneReportType) at Stimulsoft.Report.StiReport.ScriptUpdate(Object standaloneReportType, Boolean allowUseResources) at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate, Object standaloneReportType) at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate) at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType, Boolean autoCreate) at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType) at Stimulsoft.Report.StiReport.Compile(StiOutputType outputType) at Stimulsoft.Report.StiReport.Compile() at Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState) at Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState) at Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode) at Stimulsoft.Report.StiReport.Render(StiRenderState renderState) at Stimulsoft.Report.StiReport.Render(Boolean showProgress, Int32 fromPage, Int32 toPage) at Stimulsoft.Report.StiReport.Render(Boolean showProgress) at Stimulsoft.Report.StiReport.Render() at OrBitCoreService.CLRService.CLR_MRZPrint(String& ReturnMessage, String SQLString, String MRZFile, String PrinterOrFile, Int32 ImageResolution) in D:\OrBitCoreService\CLRService.cs:line 3265
Lech Kulikowski
Posts: 6291
Joined: Tue Mar 20, 2018 5:34 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Lech Kulikowski »

Hello,

Please check the following samples:
https://github.com/stimulsoft/Samples-R ... rom%20Code

Thank you.
User avatar
Woodcutter
Posts: 56
Joined: Wed Mar 01, 2017 2:17 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Woodcutter »

Hey Lech

This code works OK, thank you.
but in the Stimulsoft.Reports.Engine.NetCore 2024.2.2
there is a new problem for display Chinese characters.
Attachments
20240422085651.png
20240422085651.png (313.02 KiB) Viewed 201 times
Lech Kulikowski
Posts: 6291
Joined: Tue Mar 20, 2018 5:34 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Lech Kulikowski »

Hello,

Most of the standard fonts do not contain national characters. In this case, Windows uses the "font fallback". This algorithm is very complicated and, therefore, is not realized in the exports. To output national characters, please, use the font which contains all necessary characters. For example, the "Arial Unicode MS" font contains many national characters.

Also, you should load the font file to a special font collection using
StiFontCollection.AddFontFile(name).

Thank you.
User avatar
Woodcutter
Posts: 56
Joined: Wed Mar 01, 2017 2:17 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Woodcutter »

Although when I use "Arial Unicode MS", the Chinese characters is missing yet.

In Stimulsoft reports for .NET Framework , this problem is not exists .
Lech Kulikowski
Posts: 6291
Joined: Tue Mar 20, 2018 5:34 am

Re: System.IO.FileNotFoundException: Could not load file or assembly System.Windows.Forms

Post by Lech Kulikowski »

Hello,

Do you add the file in the font collection?

Thank you.
Post Reply