TuesPechkin icon indicating copy to clipboard operation
TuesPechkin copied to clipboard

System.Runtime.Serialization.SerializationException on Convert call

Open gerhardjj opened this issue 9 years ago • 1 comments

Hi, I'm trying to get this going as per your sample, but struggling - i'm sure it is me but can't find anyone else with a related problem....:) Thanks in advance! I'm using VS2015 (image with references at the bottom) and i receive the following error:

_An exception of type 'System.Runtime.Serialization.SerializationException' occurred in TuesPechkin.dll but was not handled in user code

Additional information: Type 'Microsoft.AspNet.Diagnostics.Entity.DataStoreErrorLogger+DataStoreErrorLog' in assembly 'Microsoft.AspNet.Diagnostics.Entity, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' is not marked as serializable._

on this call: byte[] result = converter.Convert(document);

Full code is below:

var document = new HtmlToPdfDocument
            {
                GlobalSettings =
    {
        ProduceOutline = true,
        DocumentTitle = "Pretty Websites",
        PaperSize = PaperKind.A4, // Implicit conversion to PechkinPaperSize
        Margins =
        {
            All = 1.375,
            Unit = Unit.Centimeters
        }
    },
                Objects = {
        new ObjectSettings { HtmlText = "Pretty Websites This might take a bit to convert!" }
    }
            };

        IConverter converter =
new ThreadSafeConverter(
    new RemotingToolset<PdfToolset>(
        new Win32EmbeddedDeployment(
            new TempFolderDeployment())));

        // Keep the converter somewhere static, or as a singleton instance!
        // Do NOT run the above code more than once in the application lifecycle!

        byte[] result = converter.Convert(document);

image

gerhardjj avatar Feb 19 '16 06:02 gerhardjj

I have the exact same issue. I solved it temporarily by removing the call to app.UseDatabaseErrorPage(); in the Configure method of Startup.cs. After doing that the pdf was generated just fine. I have no idea why that fixed it or why that was causing an issue though.

motohead400 avatar Oct 24 '16 17:10 motohead400