FastReport icon indicating copy to clipboard operation
FastReport copied to clipboard

FastReport Not supper .NET9.0 PublishAot

Open qwertzou opened this issue 11 months ago • 8 comments

Describe the bug Using .NET9.0 AOT to compile into a library, there was an error when calling Java/C #

To Reproduce

Image

Stacktrace Unhandled exception. System.MissingMethodException: No parameterless constructor defined for type 'FastReport.ReportPage'. at System.ActivatorImplementation.CreateInstance(Type, Boolean) + 0x176 at FastReport.Utils.FRReader.Read() + 0x1c7 at FastReport.Base.DeserializeSubItems(FRReader) + 0x17 at FastReport.Base.Deserialize(FRReader) + 0x42 at FastReport.Report.Deserialize(FRReader) + 0x74 at FastReport.Utils.FRReader.Read(IFRSerializable) + 0x99 at FastReport.Report.Load(Stream) + 0x150 at FastReport.Report.Load(String) + 0x80

Device (please complete the following information):

  • OS: win11
  • Version 2025.1.0

qwertzou avatar Mar 20 '25 02:03 qwertzou

Discovered that the error was caused here:FastReport/FastReport.Base/Utils/FRReader.cs Read() result = Activator.CreateInstance(type) as IFRSerializable; not supported

qwertzou avatar Mar 20 '25 07:03 qwertzou

Hello!

Thank you for your appeal!

Could you please send a problematic application to reproduce this error

Best regards, Bogdan

BogdanStegachev avatar Mar 21 '25 12:03 BogdanStegachev

Temporary solution:

<ItemGroup>
  <RdXmlFile Include="rd.xml" />
</ItemGroup>
rd.xml:
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <Assembly Name="FastReport" Dynamic="Required All"/>
  </Application>
</Directives>

qwertzou avatar Mar 27 '25 01:03 qwertzou

Hello!

Thank you for your appeal!

Could you please send a problematic application to reproduce this error

Best regards, Bogdan

This is a problematic application:https://github.com/qwertzou/FastReport.NET9.AOT.DEMO

qwertzou avatar Mar 27 '25 04:03 qwertzou

Hello!

I send you an example of the built library below

win-x86.zip

Best regards, Bogdan

BogdanStegachev avatar Mar 27 '25 13:03 BogdanStegachev

Hello!

I send you an example of the built library below

win-x86.zip

Best regards, Bogdan

I'm sorry, maybe I didn't express the problem clearly Please try using the command to publish: dotnet publish -c Release -r win-x86 /p:PublishAot=true

qwertzou avatar Mar 28 '25 09:03 qwertzou

Regarding NET NativeAOT, please see here https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=windows%2Cnet8

qwertzou avatar Mar 28 '25 09:03 qwertzou

I am sending you the test application below.

https://www.dropbox.com/scl/fi/4kbswm7gisjts3d87svak/Test.zip?rlkey=1e3yui365tay3wq1cp4q8f19q&st=o6b39nda&dl=0

Best regards, Bogdan

BogdanStegachev avatar Jun 19 '25 08:06 BogdanStegachev

I am sending you the test application below.

https://www.dropbox.com/scl/fi/4kbswm7gisjts3d87svak/Test.zip?rlkey=1e3yui365tay3wq1cp4q8f19q&st=o6b39nda&dl=0

Best regards, Bogdan

Thank you for your reply. I have downloaded and tested your testing application, and the problem has occurred

Image

qwertzou avatar Jun 19 '25 08:06 qwertzou

I created a task based on your request and sent it to the development department. As soon as there are changes, we will notify you immediately.

Best regards, Bogdan

BogdanStegachev avatar Jun 19 '25 08:06 BogdanStegachev

Hello!

For the FastReport library to work correctly, it must be added to the trimming exception.

I am sending you the test project below.

Best regards, Bogdan

BogdanStegachev avatar Jun 20 '25 10:06 BogdanStegachev