title: Error "Faulting application w3wp.exe..." found in event viewer if printing crystal reports in a loop
body: <p>I'm developing a web app using  VS.Net 2010 &amp; embedded CR which would run on MS 2008 and IIS 7.
  One of the functions is to update database records ( ~20-50) and print a crystal report to a network printer for each record in a for loop. (Due to the business need, report has to print one by one)
  The function works fine in my machine. It also works on the server if the report is printed to a PDF printer.</p>
  
  <p>However, if it is printed to a physical network printer, the captioned error prompts in event viewer after several loops; no exception returned in the page and it just stops at a point and page loads until timeout.</p>
  
  <p>I added logging in the program and found that the loop could stop at anywhere, i.e.  creating a new crystal report, setting report data source assigning printer name, updated record...</p>
  
  <p>Below is fragment of code in printing the report, very simple:</p>
  
  <pre><code>rptDoc.PrintOptions.PrinterName = strPrinterName;
  
  rptDoc.PrintToPrinter(intPrintCopy, false, 0, 0);
  </code></pre>
  
  <p>If above codes are commented, the error doesnt happen any more and the for loop can complete everytime no matter how many records.</p>
  
  <p>The faulting modules could be ntdll.dll (most), crpe32.dll, kernel32.dll, MSVCR80.dll etc; Below are some error messages captured:</p>
  
  <ul>
  <li><p>Faulting application w3wp.exe, version 7.0.6001.18000, time stamp 0x47919ed8, faulting module ntdll.dll, version 6.0.6001.18538, time stamp 0x4cb73957, exception code 0xc0000005, fault offset 0x0000000000046ef0, process id 0x%9, application start time 0x%10.</p></li>
  <li><p>Faulting application w3wp.exe, version 7.0.6001.18000, time stamp 0x47919ed8, faulting module kernel32.dll, version 6.0.6001.18631, time stamp 0x4da46d09, exception code 0xe0434352, fault offset 0x0000000000025efd, process id 0x9c0, application start time 0x01ccd042bf90d940.</p></li>
  <li><p>Faulting application w3wp.exe, version 7.0.6001.18000, time stamp 0x47919ed8, faulting module crpe32.dll, version 13.0.2.469, time stamp 0x4eb91936, exception code 0xc0000005, fault offset 0x00000000002948ea, process id 0x%9, application start time 0x%10.</p></li>
  </ul>
  
  <p>I'm not familar with the server and IIS stuffs but it seems not a programming issue as it works fine on computer.
  Anyone can give me some idea?</p>
  
  <p>Thanks a lot!</p>