Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing when second request comes in/ hanging randonmly #175

Open
vsarunov opened this issue Dec 7, 2018 · 1 comment
Open

Crashing when second request comes in/ hanging randonmly #175

vsarunov opened this issue Dec 7, 2018 · 1 comment

Comments

@vsarunov
Copy link

vsarunov commented Dec 7, 2018

Hi,

When we use the following piece of code the application crashes on the line converter.Convert(document); when second request comes in to convert.

   private static readonly IToolset toolset;
    private static readonly IConverter converter;

    static PdfBuilder()
    {
        toolset = new PdfToolset(new WinAnyCPUEmbeddedDeployment(new TempFolderDeployment()));
        converter = new ThreadSafeConverter(toolset);
    }

    public byte[] BuildPdf(string html)
    {
        var document = new HtmlToPdfDocument
        {
            Objects = { new ObjectSettings { HtmlText = html }, }
        };

        try
        {
            var result = converter.Convert(document);
            toolset.Unload();
            return result;
        }
        catch (Exception e)
        {
            throw;
        }
    }

When we use this piece of code bellow, the application works fine, though periodically it starts hanging, which lead me to the above piece of code and trying to uload.

private static readonly IConverter converter = new ThreadSafeConverter(new PdfToolset(new WinAnyCPUEmbeddedDeployment(new TempFolderDeployment())));

    public byte[] BuildPdf(string html)
    {
        var document = new HtmlToPdfDocument
        {
            Objects = { new ObjectSettings { HtmlText = html}, }
        };

        try
        {

            return converter.Convert(document);
        }
        catch (Exception e)
        {

            throw;
        }
    }

I have read similar issues here, however I have not found a solution which would work, any help on this one?

@tloy1966
Copy link

tloy1966 commented Apr 8, 2019

any exception? or just hanging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants