facebooktwittermenuarrow-up

GemBox Support Forum

The type initializer threw an exception in Xamarin Forms

I am trying to generate a pdf document in xamarin forms using Gembox Document’s DocumentModel and I am getting the following error

image

I Have a this code

Hi Luis,

I’m afraid that the screenshot is not clear.
Can you post here the exception and the inner exception as text?

Regards,
Mario

ex.Message:
The type initializer for ‘ ​’ threw an exception.

ex.StackTrace:

StackTrace

at GemBox.Document.PdfSaveOptions.67tg5rkvl9zwp8v7723mndgzuc3b4vj8 (GemBox.Document.DocumentModel , System.IO.Stream , System.String ) [0x00017] in :0
at GemBox.Document.DocumentModel.Save (System.String path, GemBox.Document.SaveOptions options) [0x0002f] in :0
at GemBox.Document.DocumentModel.Save (System.String path) [0x0001b] in :0
at TimelineNewList.MainPage.CreateDocument2 () [0x000ad] in D:\CodesVis\TimelineNewList\TimelineNewList\TimelineNewList\MainPage.xaml.cs:245
at TimelineNewList.MainPage.<Button_ClickedAsync>b__4_0 () [0x00000] in D:\CodesVis\TimelineNewList\TimelineNewList\TimelineNewList\MainPage.xaml.cs:268
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:534
at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
— End of stack trace from previous location where exception was thrown —

at TimelineNewList.MainPage.Button_ClickedAsync (System.Object sender, System.EventArgs e) [0x00040] in D:\CodesVis\TimelineNewList\TimelineNewList\TimelineNewList\MainPage.xaml.cs:268

source
Gembox.Document

ex.InnerException.Message:
The type initializer for ‘ ​’ threw an exception.

ex.InnerException.StackTrace:

StackTrace

at ​…cctor () [0x00000] in :0

source
System.Drawing.Common

ex.InnerException.InnerException.Message:
Operation is not supported on this platform.

ex.InnerException.InnerException.StackTrace:

StackTrace

at System.Drawing.Imaging.ImageFormat.get_Jpeg () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/Facades/System.Drawing.Common/Stubs.cs:2318
at ​…cctor () [0x00000] in :0

Hi,

I believe this issue was already solved, can you please try again with the latest BugFix version or the latest NuGet package.

Does this solve your issue?

Last, GemBox.Document’s PDF writer currently uses System.Drawing for processing images.
But I’m afraid it’s possible that it won’t work well on Xamarin.

Nevertheless, note that we do have plans for investigating the possibility of removing/replacing this dependency in the current road-map.
At the moment, I don’t have any release date to share, but if I had to guess I would say that we’ll probably start working on this before the end of this year.

Regards,
Mario