This error seems to emanate from from the actual component (especially since it appears to be pointing at some native code which that library calls).
Hi everyone,
I am using the wkHtmlToXSharp Dotnet library to convert HTML pages to PDF files. The DLL is used using the wwDotNetBridge code. All works well for the first few conversions, but randomly, the DLL crashes with the following error, when the InvokeMethod :
"OLE iDispach exception code 0 from wwDotNetBridge attempted to read or write protected memory. This is often an undication that memory corrupt"
Just to brief everyone, we use a ssWkHtmlToXSharp.dll file for the conversion which is created using the following ilmerge command.
"D:\Program Files\Microsoft\ILMerge\ilmerge.exe" /keyfile:WkHtmlToXSharp.Snk /target:library /out:ssWkHtmlToXSharp.dll Common.Logging.dll WkHtmlToXSharp.dll
The fox Code for the object that calls the wwDotNetBridge object is :
DEFINECLASS html2Pdf AS Relation
oBridge = null
oConvertor = null
cErrorMsg = ""
lNoInterface = .F. FUNCTIONInit()IFISNULL(App.oBRidge)App.oBridge = NEWOBJECT("wwDotNetBridge","\shcommon\wconnect\classes\wwDotNetBridge.prg","",[V4])ENDIFTHIS.oBridge = App.oBridgeTHIS.oBridge.LoadAssembly("ssWkHtmlToXSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a62b1b93e623d45b")THIS.oConvertor = THIS.oBridge.CreateInstance("WkHtmlToXSharp.WkHtmlToPdfConverter")IFISNULL(THIS.oConvertor)THIS.cErrorMsg = "Error: Reported from Html2Pdf object:;;" + THIS.oBridge.cErrorMsgIF NOT THIS.lNoInterface
=WMESS(THIS.cErrorMsg)ENDIFENDIFENDFUNCFUNCTION GenPdf(m.cSourceHtml , m.cTargetPdf)PRIVATE ALL EXCEPT APP*THIS.cErrorMsg = ""IF !FILE(m.cSourceHtml)THIS.cErrorMsg = "File " + ALLTRIM(m.cSourceHtml) + " does not exist."RETURN .F.ENDIFIFVARTYPE(m.cTargetPdf)="L"
m.cTargetPdf = FORCEEXT(m.cSourceHtml,"pdf")ENDIFERASE (m.cTargetPdf)
=STRTOFILE(THIS.oBridge.InvokeMethod(THIS.oConvertor, "Convert", FILETOSTR(m.cSourceHtml)), m.cTargetPdf)ENDFUNCENDDEFINE
I am scratching my head for a long time and just cannot figure out the reason for this. Any help will be eternally appreciated.
Thanks a Ton
Abhay