Aspose.PDF is not working with .NET 6.0 version

Hi Team, Please help me the below one.

We have upgraded our project from .Net core 3.1 to .Net 6.0 but Aspose.pdf is working fine in .Net 3.1 version but not working in .Net 6.0 version. Please see error details below.

Error: System.Exception: The type initializer for ‘#=zM7AY1E9$Rk7N9CxYFV8Os59Pb5tAqCXs4Q==’ threw an exception.

@riyazahamedj0101

We already logged an issue to test Aspose.PDF functionality under .NET 6.0 in non-Windows environments as PDFNET-50918. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Could you please share the operating system name that you are using?

Hi Tahir,

LINUX

Thanks for your reply
Riyaz Ahamed J

@riyazahamedj0101

Thanks for sharing the detail. We will inform you once there is an update available on PDFNET-50918.

Please let us know if any update on this .

Current code:
[HttpPost]
[Route(“api/services/ExportPdf”)]
public IActionResult ExportPdf([FromBody] ExportPdf request)
{
Aspose.Pdf.License licPDF = new Aspose.Pdf.License();
licPDF.SetLicense(“Aspose.Total.NET.lic”);
string fileName = “AgenciesList” + “.pdf”;
string HtmlString = request.HTMLContent;
Document doc = new Document();
Page page = doc.Pages.Add();
HtmlFragment htmlFragment = new HtmlFragment(HtmlString);
page.Paragraphs.Add(htmlFragment);
Stream outputStream = new MemoryStream();
doc.Save(outputStream);
return File(outputStream, System.Net.Mime.MediaTypeNames.Application.Pdf, fileName);
}

@riyazahamedj0101

Unfortunately, there is no update available on this feature. We will be sure to inform you via this forum thread once there is an update available on it.

Hi Serget,

The Aspose.PDF.Drawing is not supported on .NET 6.

Thanks
Riyaz Ahamed J

@riyazahamedj0101

Aspose.PDF.Drawing NuGet package has been released in Aspose.PDF for .NET 23.1. The DLL in this package does not have System.Drawing.Common dependency. We will inform you once new version of Aspose.PDF for .NET is released.

Hi Team,

Please help me for Aspose.PDF with .NET 6.0, it is urgent.

Please let us know if any update.

Thanks
Riyaz Ahamed J

@riyazahamedj0101

Aspose.PDF.Drawing NuGet package was released, DLL in this package doesn’t have System.Drawing.Common dependency.

You only need to install Aspose.PDF.Drawing instead of Aspose.PDF. Aspsoe.PDF with Drawing contains Aspose.Drawing inside, installing neither System.Drawing nor Aspose.Drawing is required.

This assembly correctly works under Linux environment. It will be published as separated assembly until we sure that this works absolutely perfect and may replace current System.Drawing-based assembly by 100%. When we ensure that, we will replace System.Drawing version with Aspose.Drawing one.

Hi @asad.ali
I have installed Aspose.PDF.Drawing and un installed Aspose.PDF but not working.
Error : System.Exception:The type initializer for ‘#=zCsXa80MpWj9mFTt5D7y3Je_gE2IwxrSf$g==’ threw an exception.

Note: We have migrated .NET core 3.1 to .NET 6.0 now, it is working fine in locally but not working in server

Thanks
Riyaz Ahamed J

@riyazahamedj0101

Would you kindly make sure that only Aspose.PDF.Drawing is being used on the server where the application has been deployed. Otherwise, can you please share the complete exception message and stack trace so that we can try to investigated further. Please share the complete OS Name and Version that is running on the server.

Server : Linux
Error:

{"messageType": "DATA_MESSAGE", "owner": "917425986053", "logGroup": "ifcopdev-im-services-api", "logStream": "SC-917425986053-pp-bswm6s4o7o4wo/im-dev-im-services/c2d5796b02db4bd6b8c16b1d22a62ea4", "subscriptionFilters": ["ifcopdev-im-services-api"], "logEvents": [{"id": "37344032936241069488539533127994048884329977234809946112", "timestamp": 1674564352168, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Hosting.Diagnostics[1]"}, {"id": "37344032936241069488539533127994048884329977234809946113", "timestamp": 1674564352168, "message": " Request starting HTTP/1.1 POST http://imdev.ifc.org/api/services/ExportPdf application/json 21995"}, {"id": "37344032936241069488539533127994048884329977234809946114", "timestamp": 1674564352168, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Cors.Infrastructure.CorsService[4]"}, {"id": "37344032936241069488539533127994048884329977234809946115", "timestamp": 1674564352168, "message": " CORS policy execution successful."}, {"id": "37344032936263370233738063751135584602602625596315926532", "timestamp": 1674564352169, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[1]"}, {"id": "37344032936263370233738063751135584602602625596315926533", "timestamp": 1674564352169, "message": " Failed to validate the token."}, {"id": "37344032936263370233738063751135584602602625596315926534", "timestamp": 1674564352169, "message": " Microsoft.IdentityModel.Tokens.SecurityTokenSignatureKeyNotFoundException: IDX10501: Signature validation failed. Unable to match key: "}, {"id": "37344032936263370233738063751135584602602625596315926535", "timestamp": 1674564352169, "message": " kid: '-KI3Q9nNR7bRofxmeZoXqbHZGew'. "}, {"id": "37344032936263370233738063751135584602602625596315926536", "timestamp": 1674564352169, "message": " Number of keys in TokenValidationParameters: '2'. "}, {"id": "37344032936263370233738063751135584602602625596315926537", "timestamp": 1674564352169, "message": " Number of keys in Configuration: '0'. "}, {"id": "37344032936263370233738063751135584602602625596315926538", "timestamp": 1674564352169, "message": " Exceptions caught:"}, {"id": "37344032936263370233738063751135584602602625596315926539", "timestamp": 1674564352169, "message": " '[PII of type 'System.Text.StringBuilder' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. "}, {"id": "37344032936263370233738063751135584602602625596315926540", "timestamp": 1674564352169, "message": " token: '[PII of type 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'."}, {"id": "37344032936263370233738063751135584602602625596315926541", "timestamp": 1674564352169, "message": " at Microsoft.IdentityModel.Tokens.InternalValidators.ValidateLifetimeAndIssuerAfterSignatureNotValidatedJwt(SecurityToken securityToken, Nullable`1 notBefore, Nullable`1 expires, String kid, TokenValidationParameters validationParameters, BaseConfiguration configuration, StringBuilder exceptionStrings, Int32 numKeysInConfiguration, Int32 numKeysInTokenValidationParameters)"}, {"id": "37344032936263370233738063751135584602602625596315926542", "timestamp": 1674564352169, "message": " at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(String token, JwtSecurityToken jwtToken, TokenValidationParameters validationParameters, BaseConfiguration configuration)"}, {"id": "37344032936285670978936594374277120320875273957821906959", "timestamp": 1674564352170, "message": " at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignatureAndIssuerSecurityKey(String token, JwtSecurityToken jwtToken, TokenValidationParameters validationParameters, BaseConfiguration configuration)"}, {"id": "37344032936285670978936594374277120320875273957821906960", "timestamp": 1674564352170, "message": " at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateJWS(String token, TokenValidationParameters validationParameters, BaseConfiguration currentConfiguration, SecurityToken& signatureValidatedToken, ExceptionDispatchInfo& exceptionThrown)"}, {"id": "37344032936285670978936594374277120320875273957821906961", "timestamp": 1674564352170, "message": " --- End of stack trace from previous location ---"}, {"id": "37344032936285670978936594374277120320875273957821906962", "timestamp": 1674564352170, "message": " at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, JwtSecurityToken outerToken, TokenValidationParameters validationParameters, SecurityToken& signatureValidatedToken)"}, {"id": "37344032936285670978936594374277120320875273957821906963", "timestamp": 1674564352170, "message": " at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)"}, {"id": "37344032936285670978936594374277120320875273957821906964", "timestamp": 1674564352170, "message": " at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()"}, {"id": "37344032936285670978936594374277120320875273957821906965", "timestamp": 1674564352170, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[7]"}, {"id": "37344032936285670978936594374277120320875273957821906966", "timestamp": 1674564352170, "message": " ADFS was not authenticated. Failure message: IDX10501: Signature validation failed. Unable to match key: "}, {"id": "37344032936285670978936594374277120320875273957821906967", "timestamp": 1674564352170, "message": " kid: '-KI3Q9nNR7bRofxmeZoXqbHZGew'. "}, {"id": "37344032936285670978936594374277120320875273957821906968", "timestamp": 1674564352170, "message": " Number of keys in TokenValidationParameters: '2'. "}, {"id": "37344032936285670978936594374277120320875273957821906969", "timestamp": 1674564352170, "message": " Number of keys in Configuration: '0'. "}, {"id": "37344032936285670978936594374277120320875273957821906970", "timestamp": 1674564352170, "message": " Exceptions caught:"}, {"id": "37344032936285670978936594374277120320875273957821906971", "timestamp": 1674564352170, "message": " '[PII of type 'System.Text.StringBuilder' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. "}, {"id": "37344032936285670978936594374277120320875273957821906972", "timestamp": 1674564352170, "message": " token: '[PII of type 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'."}, {"id": "37344032936285670978936594374277120320875273957821906973", "timestamp": 1674564352170, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]"}, {"id": "37344032936285670978936594374277120320875273957821906974", "timestamp": 1674564352170, "message": " Executing endpoint 'IFC.CITFO.IM.Services.API.Controllers.ExportController.ExportPdf (IFC.CITFO.IM.Services.API)'"}, {"id": "37344032936285670978936594374277120320875273957821906975", "timestamp": 1674564352170, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]"}, {"id": "37344032936285670978936594374277120320875273957821906976", "timestamp": 1674564352170, "message": " Route matched with {action = \"ExportPdf\", controller = \"Export\"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult ExportPdf(IFC.CITFO.IM.Services.BL.Model.Request.ExportPdf) on controller IFC.CITFO.IM.Services.API.Controllers.ExportController (IFC.CITFO.IM.Services.API)."}, {"id": "37344032943265804226076679417577800140214211109193777185", "timestamp": 1674564352483, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1]"}, {"id": "37344032943265804226076679417577800140214211109193777186", "timestamp": 1674564352483, "message": " Executing action method IFC.CITFO.IM.Services.API.Controllers.ExportController.ExportPdf (IFC.CITFO.IM.Services.API) - Validation state: Valid"}, {"id": "37344032952141500815091867427909016012728258988573982755", "timestamp": 1674564352881, "message": "\u001b[41m\u001b[30mfail\u001b[39m\u001b[22m\u001b[49m: IFC.CITFO.IM.Common.Utility.GlobalExceptionFilter[0]"}, {"id": "37344032952141500815091867427909016012728258988573982756", "timestamp": 1674564352881, "message": " Error for UserId:"}, {"id": "37344032952141500815091867427909016012728258988573982757", "timestamp": 1674564352881, "message": " System.Exception: The type initializer for '#=zCsXa80MpWj9mFTt5D7y3Je_gE2IwxrSf$g==' threw an exception."}, {"id": "37344032952141500815091867427909016012728258988573982758", "timestamp": 1674564352881, "message": " ---> System.TypeInitializationException: The type initializer for '#=zCsXa80MpWj9mFTt5D7y3Je_gE2IwxrSf$g==' threw an exception."}, {"id": "37344032952141500815091867427909016012728258988573982759", "timestamp": 1674564352881, "message": " ---> System.TypeInitializationException: The type initializer for '#=zkTQGGcyH1pggAJ0TxVFIg7QW$IIC' threw an exception."}, {"id": "37344032952141500815091867427909016012728258988573982760", "timestamp": 1674564352881, "message": " ---> System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')"}, {"id": "37344032952141500815091867427909016012728258988573982761", "timestamp": 1674564352881, "message": " en-US is an invalid culture identifier."}, {"id": "37344032952141500815091867427909016012728258988573982762", "timestamp": 1674564352881, "message": " at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)"}, {"id": "37344032952141500815091867427909016012728258988573982763", "timestamp": 1674564352881, "message": " at System.Globalization.CultureInfo..ctor(String name)"}, {"id": "37344032952141500815091867427909016012728258988573982764", "timestamp": 1674564352881, "message": " at #=zkTQGGcyH1pggAJ0TxVFIg7QW$IIC..cctor()"}, {"id": "37344032952141500815091867427909016012728258988573982765", "timestamp": 1674564352881, "message": " --- End of inner exception stack trace ---"}, {"id": "37344032952141500815091867427909016012728258988573982766", "timestamp": 1674564352881, "message": " at #=zCsXa80MpWj9mFTt5D7y3Je_gE2IwxrSf$g==..cctor()"}, {"id": "37344032952141500815091867427909016012728258988573982767", "timestamp": 1674564352881, "message": " --- End of inner exception stack trace ---"}, {"id": "37344032952141500815091867427909016012728258988573982768", "timestamp": 1674564352881, "message": " at #=zCsXa80MpWj9mFTt5D7y3Je_gE2IwxrSf$g==.#=z8FN3SHNAZ$Jf()"}, {"id": "37344032952141500815091867427909016012728258988573982769", "timestamp": 1674564352881, "message": " at #=zCsXa80MpWj9mFTt5D7y3Je_gE2IwxrSf$g==..ctor(#=z70y6ErxYl40f4nNHYZCOJnY= #=zMkHleXU=, #=zEGpcHFN4arQfs0uVN0HkAVioUU51 #=zf9QNDkE=)"}, {"id": "37344032952141500815091867427909016012728258988573982770", "timestamp": 1674564352881, "message": " at #=z$MvYjBHQWRGlQvB4c4tpPLjbR4ztcBuHtg==.#=z9Z3n_y0=(#=z70y6ErxYl40f4nNHYZCOJnY= #=zMkHleXU=, #=zEGpcHFN4arQfs0uVN0HkAVioUU51 #=zf9QNDkE=)"}, {"id": "37344032952141500815091867427909016012728258988573982771", "timestamp": 1674564352881, "message": " at #=z70y6ErxYl40f4nNHYZCOJnY=.#=zolmRui5zrEfS.#=zGPx7wyc8hhyF_4HbBg==.#=zncOTN9JhOKsTExXhKQ==()"}, {"id": "37344032952141500815091867427909016012728258988573982772", "timestamp": 1674564352881, "message": " at #=z5m$eNX$CrEvkJQydV$avri8=.#=zbugjSMI=()"}, {"id": "37344032952141500815091867427909016012728258988573982773", "timestamp": 1674564352881, "message": " --- End of inner exception stack trace ---"}, {"id": "37344032952141500815091867427909016012728258988573982774", "timestamp": 1674564352881, "message": " at #=zi4PAFKY$ZSDZSFkOT8TvkZ4PIU9F.#=zrtpCyaM=(Boolean #=zQny1fgs=)"}, {"id": "37344032952163801560290398051050551731000907350079963191", "timestamp": 1674564352882, "message": " at #=z70y6ErxYl40f4nNHYZCOJnY=.#=zwJB$ZDc=(#=zf$9dmY$9$HO4 #=zvV8Sgn4=)"}, {"id": "37344032952163801560290398051050551731000907350079963192", "timestamp": 1674564352882, "message": " at #=zQGCfyONCu5eUjlyZF0fwRBg=..ctor(#=ziBX9RMXY_5GaQ87RyeVBINWtn64m #=zLY13Bgk=, #=z5HGef1fC4_k7RcNS3TQAZLg= #=zf9QNDkE=, Byte #=zgjWscbw=)"}, {"id": "37344032952163801560290398051050551731000907350079963193", "timestamp": 1674564352882, "message": " at #=zQGCfyONCu5eUjlyZF0fwRBg=..ctor(Stream #=zK7CVzuo=, String #=zU2x4zjs=, #=z5HGef1fC4_k7RcNS3TQAZLg= #=zf9QNDkE=)"}, {"id": "37344032952163801560290398051050551731000907350079963194", "timestamp": 1674564352882, "message": " at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=zwMeQyJmFh7aS(Stream #=z8DmoggghDT6a, Document #=z6hZb6fnr48YG, HtmlLoadOptions #=zMsiHIAnkh1JS, String #=zLDkqgjhAMgyS)"}, {"id": "37344032952163801560290398051050551731000907350079963195", "timestamp": 1674564352882, "message": " at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=zj8C15x4=(Stream #=z8DmoggghDT6a, Document #=z6hZb6fnr48YG, HtmlLoadOptions #=zMsiHIAnkh1JS, String #=zLDkqgjhAMgyS)"}, {"id": "37344032952163801560290398051050551731000907350079963196", "timestamp": 1674564352882, "message": " at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=zj8C15x4=(Stream #=z8DmoggghDT6a, Document #=z6hZb6fnr48YG, HtmlLoadOptions #=zMsiHIAnkh1JS)"}, {"id": "37344032952163801560290398051050551731000907350079963197", "timestamp": 1674564352882, "message": " at Aspose.Pdf.Document.#=zATgXjxA=(Stream #=zU9c_a3A=, LoadOptions #=zsPgsp$M=)"}, {"id": "37344032952163801560290398051050551731000907350079963198", "timestamp": 1674564352882, "message": " at Aspose.Pdf.Document..ctor(Stream input, LoadOptions options)"}, {"id": "37344032952163801560290398051050551731000907350079963199", "timestamp": 1674564352882, "message": " at IFC.CITFO.IM.Services.API.Controllers.ExportController.ExportPdf(ExportPdf request) in /src/IFC.CITFO.IM/IFC.CITFO.IM.Services.API/Controllers/ExportController.cs:line 121"}, {"id": "37344032952163801560290398051050551731000907350079963200", "timestamp": 1674564352882, "message": " at lambda_method76(Closure , Object , Object[] )"}, {"id": "37344032952163801560290398051050551731000907350079963201", "timestamp": 1674564352882, "message": " at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)"}, {"id": "37344032952163801560290398051050551731000907350079963202", "timestamp": 1674564352882, "message": " at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)"}, {"id": "37344032952163801560290398051050551731000907350079963203", "timestamp": 1674564352882, "message": " at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"}, {"id": "37344032952163801560290398051050551731000907350079963204", "timestamp": 1674564352882, "message": " at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)"}, {"id": "37344032952163801560290398051050551731000907350079963205", "timestamp": 1674564352882, "message": " at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)"}, {"id": "37344032952163801560290398051050551731000907350079963206", "timestamp": 1674564352882, "message": " at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"}, {"id": "37344032952163801560290398051050551731000907350079963207", "timestamp": 1674564352882, "message": " at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"}, {"id": "37344032952186102305488928674192087449273555711585943624", "timestamp": 1674564352883, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]"}, {"id": "37344032952186102305488928674192087449273555711585943625", "timestamp": 1674564352883, "message": " Executed action IFC.CITFO.IM.Services.API.Controllers.ExportController.ExportPdf (IFC.CITFO.IM.Services.API) in 713.4671ms"}, {"id": "37344032952208403050687459297333623167546204073091924042", "timestamp": 1674564352884, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]"}, {"id": "37344032952208403050687459297333623167546204073091924043", "timestamp": 1674564352884, "message": " Executed endpoint 'IFC.CITFO.IM.Services.API.Controllers.ExportController.ExportPdf (IFC.CITFO.IM.Services.API)'"}, {"id": "37344032952230703795885989920475158885818852434597904460", "timestamp": 1674564352885, "message": "\u001b[40m\u001b[32minfo\u001b[39m\u001b[22m\u001b[49m: Microsoft.AspNetCore.Hosting.Diagnostics[2]"}, {"id": "37344032952230703795885989920475158885818852434597904461", "timestamp": 1674564352885, "message": " Request finished HTTP/1.1 POST http://dev/api/services/ExportPdf application/json 21995 - 500 - application/json 717.5698ms"}]}

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-53573

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.