简体   繁体   English

API删除/退出后,gsdll32.dll保持锁定状态

[英]gsdll32.dll stays locked after API delete/exit

I built a converter using GhostScriptSharp to generate full-page images of PDF files via a website, and gsdll32.dll seems to remain locked (as well as the files it generated/worked from) whenever I call GenerateOutput(). 我使用GhostScriptSharp构建了一个转换器,通过网站生成PDF文件的整页图像,每当我调用GenerateOutput()时,gsdll32.dll似乎都保持锁定状态(以及它生成/工作的文件)。

My code snippet: 我的代码片段:

GhostscriptSharp.GhostscriptWrapper.GenerateOutput(pdfFile, outputFile, settings);

Immediately after calling this, I save the resulting bytes to a blob on Azure. 调用此函数后,我立即将生成的字节保存到Azure上的blob中。 Once that's done I try to call: 一旦完成,我试着打电话:

try {
    File.Delete(outputFile); // clean up if we can
}
catch { }

Which throws an exception because the file is still locked. 由于文件仍处于锁定状态,因此会引发异常。

Then when I try to build again (either via F5 or even in live situations) I get an error saying it can't copy gsdll32.dll to my bin folder because it's locked. 然后,当我再次尝试构建时(通过F5或甚至在实时情况下)我得到一个错误,说它无法将gsdll32.dll复制到我的bin文件夹,因为它已被锁定。

I checked GhostScriptSharp against the Ghostscript API , and it seems everything is being called in the correct order. 我针对Ghostscript API检查了GhostScriptSharp,似乎所有内容都按正确顺序调用。 I can't explain why IIS is retaining a lock on gsdll32.dll, though. 我无法解释为什么IIS保留对gsdll32.dll的锁定。

Anyone run into this before? 有没有人遇到过这个? I can't seem to find anyone with a similar problem. 我似乎找不到任何有类似问题的人。

Update: I tried calling ExitAPI/DeleteAPI a second time in the catch above in case it just didn't take the first time for some reason, and it threw an AccessViolationException . 更新:我尝试在上面的catch中第二次调用ExitAPI / DeleteAPI,以防它由于某种原因而没有第一次进行,并且它抛出了一个AccessViolationException So it looks like the API is exiting properly, just IIS isn't releasing locks properly I guess? 所以看起来API正常退出,只是IIS没有正确释放锁我想?

After more research, this appears to actually be behavior between IIS and native dll imports. 经过更多研究,这似乎实际上是IIS和本机dll导入之间的行为。 For most purposes this problem can be avoided by unloading the AppDomain (ie cycling the app pool) before publishing. 在大多数情况下,可以通过在发布之前卸载AppDomain(即循环应用程序池)来避免此问题。 This is doable in a normal publishing scenario using app_offline.htm, but in an Azure continuous integration environment this is not an option (which is sad because I've had to disable CI and resort to manual publishing on my master branch). 这在使用app_offline.htm的正常发布方案中是可行的,但在Azure持续集成环境中,这不是一个选项(这很难过,因为我必须禁用CI并在我的主分支上使用手动发布)。

Any further input on how I could work around this to get builds automated would be incredibly helpful. 关于我如何解决这个问题以获得自动化构建的任何进一步的输入将是非常有帮助的。 The only workaround I have in right now involves offloading the Ghostscript dependency to a separate machine and setting up a message queue to process things (ugh). 我现在唯一的解决方法是将Ghostscript依赖关系卸载到一台单独的机器并设置一个消息队列来处理事物(呃)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM