0

i am using Spire.pdf dll for printing html pages silently, it's working fine on my machine but it's giving below error on client machine.

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.msht
ml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToke
n=b03f5f7f11d50a3a'
  at Spire.Pdf.HtmlConverter.HtmlConverter.?(String A_0, ImageType A_1, Int32 A
_2)
  at Spire.Pdf.HtmlConverter.HtmlConverter.Convert(String url, ImageType type,
Int32 width, Int32 height, AspectRatio aspectRatio)
  at Spire.Pdf.PdfSection.?(String A_0, Boolean A_1, Boolean A_2, Boolean A_3,
PdfHtmlLayoutFormat A_4)
  at Spire.Pdf.PdfDocument.LoadFromHTML(String htmlSourceCode, Boolean autoDete
ctPageBreak, PdfPageSettings setting, PdfHtmlLayoutFormat layoutFormat, Boolean
isLoadComplete)
  at Spire.Pdf.PdfDocument.LoadFromHTML(String htmlSourceCode, Boolean autoDete
ctPageBreak, PdfPageSettings setting, PdfHtmlLayoutFormat layoutFormat)
  at SP.Module1.Main() in D:\Nikhil\Project\PrintDocument\SP\Module1.vb:line 96


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].

i look at below page and tried refereeing mshtml.dll by adding reference and copying dll to local folder where exe is, may be i didn't understand fully how to use that.

Could not load file or assembly 'Microsoft.mshtml ... Strong name validation failed

if anyone can tell me how can i place on install that dll on client machine, below is the code i am using

                Dim doc As New PdfDocument()
                Dim pgSt As New PdfPageSettings()
                pgSt.Size = PdfPageSize.A4
                pgSt.SetMargins(0.5, 0.5, 0.5, 0.5)

                Dim htmlLayoutFormat As New PdfHtmlLayoutFormat()
                htmlLayoutFormat.IsWaiting = False


                ' Dim htmlpath As String = "D:\Print-code\test3.html"
                Dim source As String = response.Content ' File.ReadAllText(htmlpath)
                doc.LoadFromHTML(source, True, pgSt, htmlLayoutFormat)

                doc.PrintSettings.PrintController = New StandardPrintController()
                doc.PrintSettings.PrinterName = printer
                'doc.PrintSettings.Copies = 2
                'Print all pages with default printer
                doc.Print()
  • Seems you copied the wrong DLL. Be sure to use C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll. Or run the vendor's installer, it ought to take care of it. – Hans Passant Oct 25 '19 at 09:19
  • Hans the file path you mention is not available on my machine, i only have C:\Windows\assembly\ – Nikhil Bhivgade Oct 26 '19 at 09:46
  • It is there, Explorer won't let you see it because of a shell extension that flattens the view of the old GAC. Do this from the command line to get ahead. – Hans Passant Oct 26 '19 at 10:59
  • @Hans now with command line i am able to reach till C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\ so i just need to copy Microsoft.mshtml.dll to my local folder ? – Nikhil Bhivgade Oct 29 '19 at 12:21

2 Answers2

0

see your project set to build target x86 or x64 then use same Microsoft.mshtml.dll build version to add reference

how to known your project set build target right click at project -> select Properties -> select tab Build -> see Platform target

Guess
  • 1
-1

Spire.pdf component depends on Microsoft Internet Explorer when converts from html to pdf. Therefore, IE must be installed on the client's computers. Below is a link to the Spire.pdf support forum. You may find more information there.
https://www.e-iceblue.com/forum/could-not-load-file-or-assembly-microsoft-mshtml-version-7-t5207.html

  • IE is installed on client PC i have checked personally – Nikhil Bhivgade Oct 25 '19 at 15:45
  • I am not sure what causes this problem, but according to the support forum's chats, it likely to be related to IE. They also suggest using their "print to file" plugin. Please check if you can use that instead. It seems that they solve this problem. Please see the end of the forum page. – Farhad Rahmanifard Oct 25 '19 at 20:30
  • New plugin link: – Farhad Rahmanifard Oct 25 '19 at 20:31
  • Thanks Farhad i already checked that article but didn't worked for me i put the plugin in same folder but it's throwing error System.InvalidOperationException: The conversion provider cann't be found. Please make sure: 1. the folder "plugins" under the same folder of Spire.Pdf.dll 2. exists "plugins\HTMLConverter.dll" and other "plugins\*.dll" – Nikhil Bhivgade Nov 02 '19 at 07:58