1

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.

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I believe so. The website project runs in development mode with no problems. The web project, all C#, also works fine both locally and published to the server. Only the website project has an issue and I've narrowed the issue down the the PrintToPrinter method. All is well until I hit that statement.
1

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.

Comments

0

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

For example: CRRuntime_64bit_13_0.msi

1 Comment

Thanks, but I did that 1st, that's why the first web applications project that uses Crystal 13.02 works fine. I believe the issue is focused on the 2nd project being a website project and does not use the viewer. Under the application pool under IIS Enable 32-Bit Applications is set to True and Identity is LocalService.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.