question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception: Could not load file or assembly 'HtmlRenderer, version=1.5.0.5'

See original GitHub issue

Hello,

I am trying to convert html from a mail-body into PDF.

I have this code:

using PdfSharp;
using System;
using System.IO;
using TheArtOfDev.HtmlRenderer.PdfSharp;

namespace myNamespace.Services.Pdf
{
    public class PdfCreator : IPdfCreator
    {
        public byte[] CreateFromHtml(string bodyOriginal)
        {
            if (string.IsNullOrEmpty(bodyOriginal))
                return null;

            try
            {
                using (var outputStream = new MemoryStream())
                {
                    var pdf = PdfGenerator.GeneratePdf(bodyOriginal, PageSize.A4);
                    pdf.Save(outputStream);
                    var result = outputStream.ToArray();
                    pdf.Dispose();
                    return result;
                }               
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}

But always I call this CreateFromHtml function I got an exception:

Could not load file or assembly ‘HtmlRenderer, Version=1.5.0.5, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.

I am working with net framework 4.6.1 and I have installed HtmlRenderer with Nuget package.

I have tested the htmlrenderer.dll is in the bin folder.

Any help would be appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

15reactions
burakdgn9commented, Apr 16, 2021

HtmlRenderer.PdfSharp v1.5.0.6 is loaded as HtmlRenderer.Core v1.5.0.5. Update HtmlRenderer.Core version to v1.5.0.6.

0reactions
CoderVivekHubcommented, Mar 4, 2023

I still get below error. I update to latest version v1.5.0.6:

System.IO.FileNotFoundException: ‘Could not load file or assembly ‘HtmlRenderer, Version=1.5.0.6, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified.’

Read more comments on GitHub >

github_iconTop Results From Across the Web

Html Generate PDF Display text garbled (chinese)
The first disgusting problem I found is that I was unable to load the winforms dll into the Visual Studio Toolbox to reference...
Read more >
Unable to resolve dependencies of NuGet packages
Solution · Clear the NuGet cache files. You do this in the following way: In the toolbar of Visual Studio, navigate to Tools...
Read more >
yargs-parser 5.0.0-security.0 npmjs: ...
Government as exportable under License Exception TSU Therefore the following terms apply You agree that you will not export or re export the...
Read more >
net Core 2.0 - Package was restored using .NetFramework ...
The package may not be fully compatible. I have a . net core 2.0 console app. I'm trying to read files from TFS...
Read more >
https://distro.ibiblio.org/fatdog/packages/720/PAC...
The programs it executes are acpid: configured through a set of configuration files, which can be dropped acpid: into place by packages or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found