FastReport icon indicating copy to clipboard operation
FastReport copied to clipboard

Operation is not supported on this platform // FastReport.NET => NET 5 Project

Open ovidiumnt opened this issue 3 years ago • 18 comments

Hi!

FastReport.Net Open Source, .NET 5 project:

ERROR: System.PlatformNotSupportedException: 'Operation is not supported on this platform.'

on line: report.Prepare();

in .NetFramework (4.6x / etc) projects, everything is OK.

ovidiumnt avatar Nov 24 '21 08:11 ovidiumnt

What platform are you using: Windows, linux, android, ios or other?

Detrav avatar Nov 24 '21 08:11 Detrav

Visual Studio 2022 / Windows OS / WPF Project / NET 5.0 (also NET 6.0 the same problem) The same WPF project built with NET Framework 4.6.1 with the same Fast Report Open Source works flawless.

ovidiumnt avatar Nov 24 '21 08:11 ovidiumnt

I've checked, under such an environment, it seemed ok. Tested Text.frx from demo.

Are you using any weird objects in the report? Is there an possibility to share the report? Can you check text.frx?

Is it also possible to send the full stacktrace of the error?

Detrav avatar Nov 24 '21 08:11 Detrav

System.PlatformNotSupportedException HResult=0x80131539 Message=Operation is not supported on this platform. Source=System.CodeDom StackTrace: at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames) at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources) at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources) at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources) at FastReport.Code.AssemblyDescriptor.InternalCompile(CompilerParameters cp, CompilerResults& cr) at FastReport.Code.AssemblyDescriptor.InternalCompile() at FastReport.Code.AssemblyDescriptor.Compile() at FastReport.Report.Compile()

at FastReport.Report.Prepare(Boolean append) at FastReport.Report.Prepare()

at System.Windows.Threading.DispatcherOperation.InvokeDelegateCore() at System.Windows.Threading.DispatcherOperation.InvokeImpl()

ovidiumnt avatar Nov 24 '21 09:11 ovidiumnt

Hello @imawoinc . You install .NET 5 SDK or Runtime version? We need a test report (or project) to reproduce the error.

KirillKornienko avatar Nov 24 '21 09:11 KirillKornienko

NET 5 & 6 that comes with Visual Studio 2022.

The project was originally build with netFramework 4.6.1 (no problems here) Migrating the project to NET 6, => the issues described above.

I can't sent you the report, it's a production report.

ovidiumnt avatar Nov 24 '21 09:11 ovidiumnt

Exactly the same problem here too (please use google translate for the page): https://blog.csdn.net/hrx521/article/details/119764127

ovidiumnt avatar Nov 24 '21 09:11 ovidiumnt

What objects do you use in the report? Are you using WinForms objects (dialog controls), event handlers in the report?

KirillKornienko avatar Nov 24 '21 09:11 KirillKornienko

Are you using FastReport.OpenSource version or other? Core, NET etc.?

KirillKornienko avatar Nov 24 '21 09:11 KirillKornienko

FastReport.OpenSource FastReport.Compat FastReport.OpenSource.Data.MySql FastReport.OpenSource.Export.PdfSimple

`using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.Drawing; using System.Data; using FastReport; using FastReport.Data; using FastReport.Dialog; using FastReport.Barcode; using FastReport.Table; using FastReport.Utils;

namespace FastReport { public class ReportScript { private void Child2_BeforePrint(object sender, EventArgs e) { textDiscount.Visible = ((int)Report.GetColumnValue("view_raport_oferta.DISCOUNT") != 0);

  textNotaBand.Visible = ((string)Report.GetColumnValue("view_raport_oferta.NOTA") != "");
  textNota.Visible = ((string)Report.GetColumnValue("view_raport_oferta.NOTA") != "");
}

private void PageHeader1_BeforePrint(object sender, EventArgs e)
{
  
}

} } `

ovidiumnt avatar Nov 24 '21 09:11 ovidiumnt

Can you show References/PackageReference in your *.csproj file? for example image

KirillKornienko avatar Nov 24 '21 09:11 KirillKornienko

<ItemGroup> <PackageReference Include="FastReport.OpenSource" Version="2021.4.15" /> <PackageReference Include="FastReport.OpenSource.Data.MySql" Version="2021.4.0" /> <PackageReference Include="FastReport.OpenSource.Export.PdfSimple" Version="2021.4.15" /> <PackageReference Include="FirebaseAdmin" Version="2.2.0" /> <PackageReference Include="Google.Protobuf" Version="3.19.1" /> <PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.2.15" /> <PackageReference Include="MySql.Data" Version="8.0.27" /> <PackageReference Include="MySqlConnector" Version="2.0.0"> <Aliases>MySqlConnectorAlias</Aliases> </PackageReference> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" /> <PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.256001"> <PrivateAssets>all</PrivateAssets> </PackageReference> </ItemGroup>

ovidiumnt avatar Nov 24 '21 09:11 ovidiumnt

I have the same problem with FastReports.NET.

I bought the version PROFESSIONAL just AFTER I tested the demo. The demo is compiled in .NET Core 3.1 and works fine. But the version PROFESSIONAL is compiled in .NET Framework and does not work.

I came back to demo version until it is solved.

It is the ILSpy showing the targets: image

The last one (in blue) is the demo version which works fine. The second and third is the PRO version that does not work.

My scenario: WPF in .NET6 running on Windows 10. Visual Studio 2022

marcosgerene avatar Dec 15 '21 21:12 marcosgerene

Hi @marcosgerene. This is very strange, this behavior should not be. Here is an example of my .NET 6 vs2022 WinForms application with FastReport.Net.Pro package. Are you sure you are using the correct package? image image

KirillKornienko avatar Dec 16 '21 11:12 KirillKornienko

@KirillKornienko

I was such an idiot!

Guy, I am so sorry, I tried to use the DLL which comes in the folder of my installer because I did it with the demo version.

image

I just did not stop for a while and tried the nuget things because, as I told you, I was such an idiot =D

Thank you for your help, Marcos

marcosgerene avatar Dec 16 '21 12:12 marcosgerene

Exactly the same problem here too (please use google translate for the page): https://blog.csdn.net/hrx521/article/details/119764127

I am the author of this blog.Now,the problem has not been resolved yet.Even if i upgrade to the latest version 2022.2.9, the problem still exists.

hrx521 avatar May 29 '22 06:05 hrx521

This problem still is present. WPF core net 6 app, trying to call an empty report with a [Date].Year() field, WILL CRASH the app. Calling the same report from a WPF framework4.8 works like a charm.

FastReport is the only thing keeping me in framework 4.8

rolosoftpy avatar Jul 15 '22 06:07 rolosoftpy

image

image

the error occurs when I use nested objects, in the .net Framework version it worked normally.

WPF .net 6

did anyone find a solution?

bruno-crr avatar Jul 26 '22 21:07 bruno-crr

Same problem here. If i try call Prepare()|Print()|Show() i get System.PlatformNotSupportedException WPF net 6.0 BUT with trial version of dll from FastReport.CoreWin_Demo app works just fine, except printing - on trial version you get huge vatermark "DEMO VERSION"

mrpeje avatar Nov 07 '22 14:11 mrpeje

So, it simply still does not work for net6-windows + UseWPF?

AlekseyKrutko avatar Apr 24 '23 14:04 AlekseyKrutko

Are you still encountering the problem on version 2024.1.3?

Yamasiash avatar Jan 17 '24 11:01 Yamasiash

Are you still encountering the problem on version 2024.1.3?

Well, briefly, all the problems I'd been encountering were caused by the wrong *.Compat assembly loaded. It is something wrong in the way how the Compat or/and FastReport nugets are arranged. And if you load your app dynamically, as plug-in, using AssemblyLoadContext, then you have to pay attention. My workarround is: Target Name="CopyFastReportCompatDLL" AfterTargets="Build" Condition="'$(TargetFramework)' == 'net6.0-windows'" Message Text="Copying FastReport.Compat.dll" Importance="High" Copy SourceFiles="$(OutputPath)runtimes\any\lib\netcoreapp3.0\FastReport.Compat.dll" DestinationFolder="$(OutputPath)" Message Text="Copied FastReport.Compat.dll" Importance="High" Target

AlekseyKrutko avatar Jan 17 '24 11:01 AlekseyKrutko