FastReport icon indicating copy to clipboard operation
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'.

Open DemonJtan opened this issue 2 years ago • 11 comments

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 image

DemonJtan avatar Jun 30 '22 02:06 DemonJtan

Hello!

The problem does not reproduce Could you please describe the playback in more detail

Best regards Marat

image

MaratAlaev avatar Jul 01 '22 08:07 MaratAlaev

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

image

StephaneDelhautal avatar Jul 04 '22 13:07 StephaneDelhautal

Hello!

I cannot reproduce this error Can you provide a test project on which it can be reproduced?

Best regards Marat

MaratAlaev avatar Jul 05 '22 19:07 MaratAlaev

The error can be reproduced by using the attached project:

ExampleWPFWithFastReports.zip

valentinistrate avatar Jul 07 '22 14:07 valentinistrate

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 : image 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.

jeremyc87 avatar Jul 15 '22 06:07 jeremyc87

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!

jeremyc87 avatar Jul 18 '22 14:07 jeremyc87

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'.

image

jonmpoole80 avatar Jul 18 '22 17:07 jonmpoole80

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.SelectManySingleSelectorIterator2.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.ToArray() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.OrderedEnumerable1.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Plateforme.Core.StartupBase.<>c.<.ctor>b__4_0() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.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)

blackflys avatar Jul 19 '22 16:07 blackflys

same to me

allen3371 avatar Jul 20 '22 09:07 allen3371

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.

sayoojsushand avatar Jul 30 '22 18:07 sayoojsushand

This bug was fixed in 2022.2.17. Please, update and try it.

KirillKornienko avatar Aug 08 '22 07:08 KirillKornienko

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.

moelang avatar Sep 01 '22 06:09 moelang

Same Error! Any changes?

Kalina9001 avatar Sep 06 '22 08:09 Kalina9001

I am also receiving the same error on 2022.3.0 with .net 6

ck-sbrown avatar Sep 06 '22 19:09 ck-sbrown

Any workarounds? It is still reproducible

AlekseyKrutko avatar Apr 26 '23 13:04 AlekseyKrutko

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

AlekseyKrutko avatar Apr 27 '23 12:04 AlekseyKrutko

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

duduccosta avatar Mar 22 '24 15:03 duduccosta

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

LordRUSS avatar Mar 25 '24 16:03 LordRUSS

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

Elbunda7 avatar Mar 27 '24 08:03 Elbunda7

This error happens on PRO version too..

duduccosta avatar Mar 27 '24 12:03 duduccosta

Hello!

Reproduced this issue, created a task and passed it to the development department, expect changes soon

Best regards, Bogdan

BogdanStegachev avatar Mar 27 '24 12:03 BogdanStegachev

Is there a workaround for the most recents PRO Version?

wagenheimer avatar Mar 29 '24 00:03 wagenheimer

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

AlekseyKrutko avatar Mar 29 '24 12:03 AlekseyKrutko

Hello!

Our developers managed to solve the problem according to your request, expect changes in the next version of FastReport OpenSource

Best regards, Bogdan

BogdanStegachev avatar Apr 02 '24 07:04 BogdanStegachev