我正在使用 wkHTMLtoXSharp 包装器在 Windows 2008 R2 上调用 wkHTMLtoPDF 库。除了一个异常(exception),一切都很好。我正在从 C# Windows 服务调用包装器。在第一次运行时,转换工作完美无缺。在后续运行中,我遇到内存损坏或 AccessViolationException。修复它的唯一方法是终止运行 DLL 的进程。这似乎重置了潜在的问题。知道如何解决这个问题吗?
最佳答案
我遇到了同样的问题。我最终得到了与 rggazarian 类似的解决方案,方法是使用 wkhtmltopdf 包来自 here 然后是这段代码
public static void GenerateNewStylePDF(string domain, string url, string applicationPath)
{
var p = new Process();
var startInfo = new ProcessStartInfo
{
FileName = applicationPath + "\\bin\\wkhtmltopdf\\wkhtmltopdf.exe",
Arguments = domain + url + " \"" + applicationPath + "export.pdf\"",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
p.StartInfo = startInfo;
p.Start();
var s = p.StandardOutput.ReadToEnd();
var e = p.StandardError.ReadToEnd();
p.WaitForExit();
}
关于c# - wkHTMLtoPDF 内存损坏和 AccessViolationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9497891/