简体   繁体   中英

published website w/ Crystal Reports not running on server IIS 7.5

I have 2 visual studio 2010 projects that use Crystal reports ver 13.02 differently.

1 works and the other is getting an object reference not set to an instance of an object error.

The first app, I developed from the ground up as a web application, that uses several existing crystal reports and are working using the crystal reports viewer. Its is a web application project using asp.net 4.0 framework in c# .

The other project was an older VB website project that I upgraded from .net 2.0 to 4.0 and was working fine until I had to upgrade it to 13.02. This project does not use the viewer but only prints the data to the report. On my development laptop under visual studio it runs and prints fine, but not when published to both my laptop's IIS 7.5 and the server's IIS 7.5 .

I get this error and have exhausted every possible option. It can't be the driver as the web applications project works fine on both my machine and the server. I'm suspicious that I will be forced to convert the project to a web applications project before an answer is found... but would prefer to find an answer to resolve it as it is.

Update After further debugging I have discovered that the problem is the PrintToPrinter method that, again, works fine in development mode, but not when published.

Does your web.config file for the VB application have all the necessary Crystal references? I've been learning over the last few days that it's pretty quirky.

Resolved Issue The printer really was not found, despite being there. This is because IIS does not have the same access to resources as does users, rightfully so, and access needs to be granted through either the registry entry under the default users key or security options for the printer need to be set to an IIS account to be set under the Identity option under IIS, in the application pool that the web application is using.

The complete process is also detailed at this link SAP site where the result was two fold.

  1. I used this code snippet to loop through all available printers (I copied and pasted this from SAP, I used C# for my app and creates a list box to add) and showed them on the web page during the print process:

     Dim myPrinter As String For Each myPrinter In System.Drawing.Printing.PrinterSettings.InstalledPrinters add to list Next 
  2. Under the web server, through Computer Management I added the Local Service IIS id to the Print Operators group.

  3. Under IIS, using the " Advanced Settings " of the Application Pool the web site is using, I changed the Identity field to LocalService

  4. I verified the printer was now available by running the code snippet again and it was, then printed the report and it ran and printed fine.

It took a while to find this answer, and I could not have gotten there without the assistance provided which directed me to the answer. I hope this helps out someone else.

You need to download and install CR on you production server. *.msi

For example: CRRuntime_64bit_13_0.msi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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