System.NullRefernceException: object reference not set to an instance of an object

Hello.
I get the same message “Object reference not set to an instance of an object” on this line:

return new Document(new MemoryStream(pdfBytes), loadOptions);

This happens on Linux, but not on Windows:

We are using Aspose.PDF.Drawing v. 23.7.0

Hole log:
Error Message:
2023-09-05T11:29:42.1656019Z Test method DokumentKonvertering.Tests.Transform.AsposeHelperTests.CreateFromHtml_OK threw exception:
2023-09-05T11:29:42.1657921Z System.NullReferenceException: Object reference not set to an instance of an object.
2023-09-05T11:29:42.1659537Z Stack Trace:
2023-09-05T11:29:42.1659982Z at #=znlEvUxzsdZ95jGjqpBUJB7AJgHBG4HngTK1BTrA=.#=zsuXy3av9$OD_(#=z6jWF9ElryXArxxSr9cVW8PPSdAkXmCt1Xw== #=z0p1XIqo=, Char #=zSNJFsUo=)
2023-09-05T11:29:42.1660696Z at #=znlEvUxzsdZ95jGjqpBUJB7AJgHBG4HngTK1BTrA=.#=zsuXy3av9$OD_(#=z6jWF9ElryXArxxSr9cVW8PPSdAkXmCt1Xw== #=z0p1XIqo=)
2023-09-05T11:29:42.1661337Z at #=zTcmheW2kLJ2bX9JhY0tS17mA2VmqH5PyBA==.#=zre1H1oBNVGH0(#=zTcmheW2kLJ2bX9JhY0tS17mA2VmqH5PyBA== #=zdvZi9ks=, #=zYKcOg2Q3xi3JuIxBvlRnusI442UyyxGIrCuZ1n4= #=zUKLw3S0=, #=zrJ1k69oIrv8xJMmMblu1uyOFP0Rb1Smjkg== #=zr2drt8I=)
2023-09-05T11:29:42.1662151Z at #=zQ7Q8eeBLfKm4pIi$snx961KOkfzMQXp4_Zq8kis=…ctor(#=zTcmheW2kLJ2bX9JhY0tS17mA2VmqH5PyBA== #=zdvZi9ks=, #=zkizDnWC8chiJoEpohi2EhkcPFxD4 #=zncHgIAs=, #=zYKcOg2Q3xi3JuIxBvlRnusI442UyyxGIrCuZ1n4= #=zUKLw3S0=)
2023-09-05T11:29:42.1662896Z at #=zTcmheW2kLJ2bX9JhY0tS17mA2VmqH5PyBA==…ctor(#=zk1qssx3d51bPEvHniBteQlk= #=zvZkFd3U=, #=zYKcOg2Q3xi3JuIxBvlRnusI442UyyxGIrCuZ1n4= #=zUKLw3S0=, #=zTcmheW2kLJ2bX9JhY0tS17mA2VmqH5PyBA== #=zweYtH4rSK2XN)
2023-09-05T11:29:42.1663552Z at #=zTcmheW2kLJ2bX9JhY0tS17mA2VmqH5PyBA==…ctor(#=z0qSfyA1HudPpsglbtvviMws= #=zWCWRNaM=, #=zTcmheW2kLJ2bX9JhY0tS17mA2VmqH5PyBA== #=zweYtH4rSK2XN)
2023-09-05T11:29:42.1664471Z at #=z9LDR0$ahXcOp90XLBBrrJPf4BHv1qeCz2w==.#=zWlHr2KB38CPQ(#=z0qSfyA1HudPpsglbtvviMws= #=zWCWRNaM=, #=zDw4pDqY6K1HxxsBhgcbJpD0HGbXyUvR7hQ== #=zpo5ORUM=, #=zllZG4IaWmX8jDBPIOa_ENC_LNEA_ar9QUw== #=z0Gi4OzCAFe2M, #=zG2AGZnB97DoMQUgFWkzwZFXW5RVe #=zJcZkiKg=, #=zTcmheW2kLJ2bX9JhY0tS17mA2VmqH5PyBA== #=zweYtH4rSK2XN, #=zxqFBNF8Zl3cZbqsJQuNp1HHW2U7wkY9vXg== #=zsUpkXuDbLNppcfaByQ==)
2023-09-05T11:29:42.1666062Z at #=z9LDR0$ahXcOp90XLBBrrJPf4BHv1qeCz2w==.#=zjURZAow=(#=z0qSfyA1HudPpsglbtvviMws= #=zWCWRNaM=, #=zDw4pDqY6K1HxxsBhgcbJpD0HGbXyUvR7hQ== #=zpo5ORUM=, #=zllZG4IaWmX8jDBPIOa_ENC_LNEA_ar9QUw== #=z0Gi4OzCAFe2M, #=zxqFBNF8Zl3cZbqsJQuNp1HHW2U7wkY9vXg== #=zsUpkXuDbLNppcfaByQ==)
2023-09-05T11:29:42.1667522Z at #=zlL0yPOonjmQQdnjseL07YTzm_Ycpkynz4g==.#=zJwjHxwhbGmBS(#=zcYOwa2DKi9ikHI_NV$QWHg4= #=zCo7XP8s=, #=zuSsyhxhe9NzYlSO7nclNsZNU0czS #=zESWtFUXBW1uAIkHqRA==, #=z760mL$tXf1wE7e6SrZbXFRHR_iZe #=zFMMqLmI=, #=zSZGgSqZ8UC4pNFIXRTAFarf_nfsH #=zD8GhBsQ=, #=zmBwpalQNVdcyUlkmFZR62eSKYppX0rpaShkxj14= #=zaIGgVrG113l$4H_NtKZWX3U=, #=zZtqAzil4x3cIZnhZ85t6Gdk= #=z$iTiqzNMbIzIs40H2g==)
2023-09-05T11:29:42.1668408Z at #=zlL0yPOonjmQQdnjseL07YTzm_Ycpkynz4g==.#=ztOfq64Q=(#=z760mL$tXf1wE7e6SrZbXFRHR_iZe #=zFMMqLmI=, #=zSZGgSqZ8UC4pNFIXRTAFarf_nfsH #=zD8GhBsQ=)
2023-09-05T11:29:42.1668914Z at #=zSZGgSqZ8UC4pNFIXRTAFarf_nfsH.#=ztOfq64Q=(#=z760mL$tXf1wE7e6SrZbXFRHR_iZe #=zFMMqLmI=)
2023-09-05T11:29:42.1669463Z at #=zUNANKYRYiXODrT_f5p8vGpncCgx2yzFIvA==.#=zWpvm6Gg=()
2023-09-05T11:29:42.1669808Z at #=zUNANKYRYiXODrT_f5p8vGpncCgx2yzFIvA==.#=zbOf9gt8=()
2023-09-05T11:29:42.1670389Z at #=zlGzMeNNjDufUGzltlBhQp4wvnyboVvf6PQ==.#=z1E$Sg29TOfML(#=zx95q$KeCPqy3pzg_7HIbbAg= #=z_7$Fuvs_Rf_cyY1H9Q==, #=zSZGgSqZ8UC4pNFIXRTAFarf_nfsH[] #=z8237WSzzBfv_, #=z760mL$tXf1wE7e6SrZbXFRHR_iZe #=zFMMqLmI=, CancellationToken #=zS5D6$$M=)
2023-09-05T11:29:42.1671464Z at #=zCuETAWWVHwf8kYlsKKx7zulCAckO.Render(#=z760mL$tXf1wE7e6SrZbXFRHR_iZe #=zFMMqLmI=, CancellationToken #=zS5D6$$M=, #=z0qSfyA1HudPpsglbtvviMws=[] #=zafyyJQ4=, #=zcYOwa2DKi9ikHI_NV$QWHg4=[] #=zxF16xzw=)
2023-09-05T11:29:42.1672095Z at #=zCuETAWWVHwf8kYlsKKx7zulCAckO.Render(#=z760mL$tXf1wE7e6SrZbXFRHR_iZe #=zFMMqLmI=, TimeSpan #=zrLkaIsY=, #=zcYOwa2DKi9ikHI_NV$QWHg4=[] #=zxF16xzw=)
2023-09-05T11:29:42.1672801Z at #=zphza2laDM5FdyuXJutMfPyYvQwV1.Render(#=z760mL$tXf1wE7e6SrZbXFRHR_iZe #=zFMMqLmI=, #=z_paH9b0= #=zCo7XP8s=, TimeSpan #=zrLkaIsY=)
2023-09-05T11:29:42.1673289Z at #=zphza2laDM5FdyuXJutMfPyYvQwV1.Render(#=z760mL$tXf1wE7e6SrZbXFRHR_iZe #=zFMMqLmI=, #=z_paH9b0= #=zCo7XP8s=)
2023-09-05T11:29:42.1673796Z at #=zCQRcefdqjS9xXXQX$B1Z3VWaaACx.#=z$GVWHqGhxkKD(Stream #=zF5D1cMJTvHml, Document #=zCoyL0DfYnSmT, HtmlLoadOptions #=zTJaKW5uAQ9uj, String #=z9T1K$Zi08Uom)
2023-09-05T11:29:42.1674362Z at #=zCQRcefdqjS9xXXQX$B1Z3VWaaACx.#=z3Q7zvR0=(Stream #=zF5D1cMJTvHml, Document #=zCoyL0DfYnSmT, HtmlLoadOptions #=zTJaKW5uAQ9uj, String #=z9T1K$Zi08Uom)
2023-09-05T11:29:42.1674893Z at #=zCQRcefdqjS9xXXQX$B1Z3VWaaACx.#=z3Q7zvR0=(Stream #=zF5D1cMJTvHml, Document #=zCoyL0DfYnSmT, HtmlLoadOptions #=zTJaKW5uAQ9uj)
2023-09-05T11:29:42.1675317Z at Aspose.Pdf.Document.#=ziu3IFPM=(Stream #=zh$Ez3JE=, LoadOptions #=zLOZHe1U=)
2023-09-05T11:29:42.1675688Z at Aspose.Pdf.Document…ctor(Stream input, LoadOptions options)
2023-09-05T11:29:42.1676281Z at DokumentKonvertering.Logic.Utilities.AsposePdfHelper.CreateDocument(Byte[] pdfBytes, LoadOptions loadOptions) in /agent/_work/18/s/Source/DokumentKonvertering/DokumentKonvertering.Logic/Utilities/AsposePdfHelper.cs:line 37
2023-09-05T11:29:42.1676996Z at DokumentKonvertering.Logic.Utilities.AsposePdfHelper.CreateFromHtml(Byte[] html) in /agent/_work/18/s/Source/DokumentKonvertering/DokumentKonvertering.Logic/Utilities/AsposePdfHelper.cs:line 99
2023-09-05T11:29:42.1677690Z at DokumentKonvertering.Tests.Transform.AsposeHelperTests.CreateFromHtml_OK() in /agent/_work/18/s/Source/DokumentKonvertering/DokumentKonvertering.Tests/Transform/AsposeHelperTests.cs:line 45

This was solved for me upgrading to Aspose.PDF.Drawing v.23.8.0

@koo1540

Its nice to know that your issue has been resolved. Please keep using the API and feel free to create a new topic in case you face any issues.

This seems to not be the exactly truth. You also seem to need the libgdiplus package installed on the Linux server. Are you aware of this and will you be removing this dependency in the (near) future?

@koo1540

Yes, we are aware of this dependency. libgdiplus and msttcorefonts packages need to be installed in non-Windows or Linux like environment in order to get the API working correctly. An investigation ticket as PDFNET-55450 has been logged in our issue tracking system to analyze removal of libgdiplus dependency. We will inform you as soon as the ticket is resolved. Please spare us some time.

Hi.

What’s the status regarding removal of dependency on libgdiplus in Linux environments?

@koo1540

We have published a beta API i.e. Aspose.Pdf.Drawing which does not include the dependency on System.Drawing and we launched it specifically to work in both Windows and Linux like platforms. Furthermore, there is no need to install the libgdiplus library - in .Net 7 it is not supported. You can try to use Aspose.Pdf.Drawing in the Linux platform to see if it is working correctly. Once we are sure that everything is fine, we will make it permanent part of existing Aspose.PDF for .NET API. Until then, you won’t need any separate license or code change to use this API. It has all classes same as existing Aspose.PDF for .NET.