Free Support Forum - aspose.com

Aspose.Cells cannot call its own System.Text.Encoding.CodePages dependency

It seems that due to the AllowPartiallyTrustedCallers attribute, when my assembly calls Aspose, it (Aspose) cannot call its own dependency on System.Text.CodePages dll due to System.Text.Encoding.CodePages being SecurityCritical. Anyone seen this before?

System.TypeInitializationException : The type initializer for ‘Aspose.Cells.Workbook’ threw an exception.
----> System.MethodAccessException : Attempt by security transparent method ‘Aspose.Cells.Workbook…cctor()’ to access security critical method ‘System.Text.CodePagesEncodingProvider.get_Instance()’ failed.

Assembly ‘Aspose.Cells, Version=18.10.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.

@WolfVasa,

Thanks for your query.

Please share your console application(runnable) and sample file(if any) with us for our testing. We will reproduce the problem and provide our feedback after analysis.

This happens when you reference .netstandard20 libraries in .net 4.6 projects

@xumix,

Please use Aspose.Cells.Dll library (in net4.0 folder) in .NET Framework 4.6 projects. For .NET Core and .NET Standard applications, you may use Aspose.Cells assembly from netstandard20 folder.