0

An ASP.NET invoice application has a save button, that triggers (among other things) the generation of a pdf file on disk using the form data, the userID etc.

An excerpt from the GeneratePDF method:

ManualResetEvent generateInvoiceEvent;
generateInvoiceEvent = new ManualResetEvent(false);
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
ThreadPool.QueueUserWorkItem(delegate
    {
        Thread.CurrentThread.CurrentCulture = currentCulture;
        Thread.CurrentThread.CurrentUICulture = currentCulture;
        InvoicePdfGenerator generator = new InvoicePdfGenerator();
        generator.SetTranslationFile(GetFileSharedFilePath());
        generator.DrawPdf(invoiceXml, pdfFilePath, invoiceLanguage.ValueCode,
            currentCulture, invoiceLayoutXml, imageRootFolder);
        generateInvoiceEvent.Set(); //Signal completion of invoice generation
    }
);
generateInvoiceEvent.WaitOne();

For some reason, the WaitOne() method throws an AccessViolation most of the time but not always, but I don't seem to able to debug further than that. Beyond that is mscorlib.

Three things are important to understand in this story:

  • This is not my code
  • I have little knowledge about threading. It's just something I rarely come into contact with in my job.
  • This worked fine up until a few weeks ago on my development machine. Chances are, that some external factor is causing this, but I cannot find what or why. There are no code updates between then and now.

It's quite possible, that this question needs additional info. As my understanding of threading is severely limited, I will update my question at your request.

4

1 回答 1

0

显然(不要在这里开枪,我意识到这是可怕的,可怕的编码,因为它除了不能取消进程之外什么都不能解决)我可以通过将上述代码块包含在try-catch.
可悲的是,这并没有透露任何可能导致AccessViolation.

于 2013-10-30T13:09:22.340 回答