FastReport
FastReport copied to clipboard
System.TypeLoadException: Could not load type 'System.Windows.Forms.AnchorStyles' from assembly 'FastReport.Compat, Version=2022.2.0.0, Culture=neutral, PublicKeyToken=406e1f4c3c8ef97e'.
The latest version Release2022.2.12,when I use the following code "Report report = new Report();" in my .NET 5.0 Project,there throws a exception
Hello!
The problem does not reproduce Could you please describe the playback in more detail
Best regards Marat
Hi,
same error for me. i have create a a report with fastreport designer and save it as vb class file. in visual studio, i have a sample projet, put the report vb class in the projet directory , this file contains the class definition FicheSuiviAssemblage in my main form, i have added a button with this code: Dim MyReport As New FicheSuiviAssemblage complition is fine. and when i run the projet and click on my button, the error is triggered on this instruction
Hello!
I cannot reproduce this error Can you provide a test project on which it can be reproduced?
Best regards Marat
I have the exact same problem here. I am using .NET 6.0 in WPF.
The error also occur if I use report.FromFile().
I have used FastReport Community to create the report. I have check the options of the report and I have discovered that :
The reference to the System.Windows.Forms.dll, look suspicious to me as we are in WPF there should not be any reference to WinForm dll...
I hope my information can help.
Hello again,
Because of this issue I am not able to test this product properly and I must make a decision quickly.
Is somebody working on it? Did you have any idea how to fix it and when can we expect a working version?
I know it's a free version and as such the support is not as quick and as "performing" but I really like the idea of this product and I would be sad to discard it because a little bug like that make me unable to properly test it.
Thanks anyway and good luck with this. Best regards!
Just ran into this myself and this topic was the first result when googling it. I am also having the issue in Report.ReadFromFile().
Edit: I went back to 2022.1.14 version of FastReport.Core and it seems to be working there.
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'FastReport.Report' threw an exception.
Source=FastReport
StackTrace:
at FastReport.Report.FromFile(String fileName)
at FulcrumDatabaseUpdater.frmStockReports.btnUpdate_Click(Object sender, EventArgs e) in C:\Users\jpoole.CREATIVEINFO\source\repos\Valsoft-Industrial-Division\FulcrumDatabaseUpdater\FulcrumDatabaseUpdater\frmStockReports.cs:line 98
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
TypeLoadException: Could not load type 'System.Windows.Forms.AnchorStyles' from assembly 'FastReport.Compat, Version=2022.2.0.0, Culture=neutral, PublicKeyToken=406e1f4c3c8ef97e'.
I also have this problem, is it possible that the FastReport.Compat is referenced by multiple projects inside and not all have the same version?
EDIT; I reverted to version 2022.2.11 for it to work. all versions above were giving the same error.
Could not load type 'System.Windows.Forms.AnchorStyles' from assembly 'FastReport.Compat, Version=2022.2.0.0, Culture=neutral, PublicKeyToken=406e1f4c3c8ef97e'. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.Assembly.GetTypes() at Plateforme.Core.StartupBase.<>c.<.ctor>b__4_1(Assembly x) at System.Linq.Enumerable.SelectManySingleSelectorIterator
2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.ToArray() at System.Linq.Buffer
1..ctor(IEnumerable1 source) at System.Linq.OrderedEnumerable
1.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Plateforme.Core.StartupBase.<>c.<.ctor>b__4_0() at System.Lazy
1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy
1.CreateValue()
at System.Lazy1.get_Value() at Something.Core.StartupBase.get_ModuleInitializers() at Something.Core.StartupBase.ConfigureServices(IServiceCollection services) at Something.Core.StartupConsoleBase.ConfigureServices(IServiceCollection services) at Something.Core.Extensions.HostBuilderExtensions.UseStartup[TStartup](IHostBuilder hostBuilder)
same to me
Same issue for me using .NET 6. Temporary fix was to use FastReport.OpenSource NuGet package version 2022.1.14 For beginners: In VS go to NuGet Package Manager, search or select FastReport.OpenSource and select the version 2022.1.14 then click on Update or Install.
This bug was fixed in 2022.2.17. Please, update and try it.
I reproduced this problem in 2022.2.14/17/18, and not reproduced in 2022.1.14
This bug was fixed in 2022.2.17. Please, update and try it.
Same Error! Any changes?
I am also receiving the same error on 2022.3.0 with .net 6
Any workarounds? It is still reproducible
If anyone iterested. For me the reason was that Report usage is in a dynamicaly loaded assembly and in the way how dependencies are resolved. Using AssemblyLoadContext + AssemblyDependencyResolver fixed the problem. AssemblyDependencyResolver is not accessible for net framework. Here is a project that implements two ways. The first one reproduces the problem. WpfWithFastReportFailing.zip
I'm facing this error:
Could not load type 'System.Windows.Forms.AnchorStyles' from assembly 'FastReport.Compat, Version=2024.1.10.0, Culture=neutral, PublicKeyToken=5ceb240df42bf6e8'.
Using .NET7
I'm facing this error:
TypeLoadException: Could not load type 'System.Windows.Forms.AnchorStyles' from assembly 'FastReport.Compat, Version=2024.1.10.0, Culture=neutral, PublicKeyToken=5ceb240df42bf6e8'.
Using .NET8
This issue should not be closed, because the exception System.TypeLoadException is still throwing in version 2024.1.10 when "Report report = new Report();" is called.
Current workaround is to use a few year old version 2022.1.14 of FastReport.Opensource and 2021.3.1 version of FastReport.Compat
This error happens on PRO version too..
Hello!
Reproduced this issue, created a task and passed it to the development department, expect changes soon
Best regards, Bogdan
Is there a workaround for the most recents PRO Version?
Is there a workaround for the most recents PRO Version?
Try to ensure that \bin\Debug\net6.0-windows\runtimes\any\lib\netcoreapp3.0\FastReport.Compat.dll is loaded. I just copy it into project output root
Hello!
Our developers managed to solve the problem according to your request, expect changes in the next version of FastReport OpenSource
Best regards, Bogdan