cancel
Showing results for 
Search instead for 
Did you mean: 

Intermittent "Invalid specified printer" when switching .PrinterName

Former Member
0 Kudos

VS2008

Crystal Reports 2008

Using Assemblies:

CrystalDecisions.Windows.Forms

CrystalDecisions.Shared

Both Version 12.0.2000.0

Steps in code

Create CrystalDecisions.CrystalReports.Engine.ReportDocument (mobjReport)

Display the report using CrystalReportViewer

Button displays System.Windows.Forms.PrintDialog to user to swtich to another printer

Take the System.Windows.Forms.PrintDialog.PrinterSettings.PrinterName result and assign it to the .ReportDocument.PrintOptions.PrinterName

I beleive this is where the error occurs at, but I can't reproduce the problem on my development machine and other customers do not experience the problem either.

If objPrint.ShowDialog() = Windows.Forms.DialogResult.OK Then

mobjPrintSettings = objPrint.PrinterSettings

mobjReport.PrintOptions.PrinterName = mobjPrintSettings.PrinterName

On the Print Dialog the customer simply switches the default printer to another printer on the network, and when selecting OK on the DialogResult they get errors. But the errors are intermittent. They might not receieve the error for a few days or get the error multiple times in one day.

Customer Uses HP Printers : 9500, 8150, 1022, 2035, 3005

Error Text:

System.Runtime.InteropServices.COMException (0x80000201): Invalid printer specified. car300_payment_receipt {97AF8582-E4E4-E498-BAB3-5C83882BD5D9}.rpt at CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.ModifyPrinterName(String newVal) at CrystalDecisions.CrystalReports.Enginer.PrintOptions.set_PrinterName(String value) at ....MyClass.MyFunctionName.. ect

Intermittent Error. Can't Reproduce on development environment.

Any suggestions?

Thanks,

Jeff

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hello Jeff

1) Make sure you are using the latest runtime:

SP4 MSI

https://smpdl.sap-ag.de/~sapidp/012002523100008782532011E/cr2008sp4_redist.zip

SP4 MSM

https://smpdl.sap-ag.de/~sapidp/012002523100008782522011E/cr2008sp4_mm.zip

2) Make sure the printer drivers are updated with the latest updates also

3) Make sure the %TEM% directory is clean and that there is enough hard drive space

4) Make sure you use .close and .dispose on the report objects once you are done with them

Other than that, from your description it appears that this is one of a number of customers that has the issue. My conclusion would be that this is an environment issue (network?) and this should be considered also.

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Former Member
0 Kudos

I have seen this issue span years at my company. Lately it happens every day. I do have an issue open with SAP support. I still don't know what the proper resolution is. This has occured on every Release of Crystal Reports(runtime). Here are the facts.

1. It can work fine for months at a time.

2. It can fail back to back days.

3. It can fail after a reboot without any sucessful prints

4. For now, we are using aspnet as the application pool identity.

5. All crystal reports have "no printer" specified at design time.

6. We can have 4-8 printers configured, it does not have a significance.

7. All print drivers are up to date.

8. We do not come close to reaching print limit.

9. We are printing to local printers(tcpip port configured to network printers) on our web server. (CAn you print to a network printer?) I could not get that to work. This takes our print server out of the equation and we go directly to the printer.

10. Once it fails, the machine HAS to be rebooted for prints to be successful. Sometimes it takes multiple reboots. Outch.

11. All code has .close and dispose of the report.

I have our infrastructure team ready to trace network activity on the next failure.

This is one bug that has lived on and on. Again it is not related to performance. Some days it errors on the first print. Other times we can generate 20 print reports in an hour. That would be way below any 75 concurrent jobs system limitations.

Now I can agree its not Crystals fault, but I would like something in black and white that says this is why you are getting the error message. Sure we can redesign our print functionality, but given our printrequests, this should work as it is.

Windows 2003 Server

64bit

Virtual Server

Crystal Reports 2008

Visual Studio 2008

HP Printers(4-8) with the latest drivers.

IIS 6 (I have separated the IIS application from other non printing Crystal Applications)

I will let you know the end solution. Please join in if this issue is active in your environment.

Edited by: Patrick Boor on Jan 20, 2012 8:31 PM

0 Kudos

Hi Patrick,

I don't think this post is related, Jeff is using a windows app and yours is WEB. Also, the post was marked as answered so no one will look at it again.

I talked to Bhushan about your case because he needed more suggestions and I suggested to move to the PrintOutPutController and not use the PrintToPrinter API. It's part of the CR Basic API used in Visual Studio and the Report Engine but the PrintOutputController is more robust and if issues are reported they are fix in it and not P2P.

Even if it is an issue in P2P we will not fix it.

Thanks

Don

PS - keep the case moving along, it's better there than in here.

Former Member
0 Kudos

Don,

Thank you for a response. I will keep the case alive because I want to understand the issue and I want to see it resolvedf I went to the printoutputcontroller, how would it print without the user being prompted? Would it require a Crystal report to be exported to pdf and then call the command line Adobe print ???? I don't want to go that route because that has been documented as failing intermittently as well.

I will investigate your option but I would like resolution to the P2P method. Thanks again....

Patrick

0 Kudos

Hi Patrick,

Like I said, P2P is NOT going to be fixed. We'll fix PrintOutPutController if there is an issue.

Where and what is the Documented intermittent failure you are referring to? If it is simply use a try/catch around the process and catch and log the exception if it fails and then try again.

"how would it print without the user being prompted?" - fill in all of the info before printing starts:


private void frmMain_Load(object sender, System.EventArgs e)
{
	if (System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count > 0) 
	{
		foreach(String myPrinter in System.Drawing.Printing.PrinterSettings.InstalledPrinters ) 
		{
			cboCurrentPrinters.Items.Add(myPrinter);
		}
		cboCurrentPrinters.SelectedIndex = 0;
	} 
	else
	{
		rdoCurrent.Enabled = false;
		EnableDisableCurrentControls(false);
	}
	//For printers exposed to System account as per MS Kbase 
	//http://support.microsoft.com/default.aspx?scid=kb;en-us;184291

	//Look to HKEY_USERS\.Default\Software\Microsoft\Windows NT\CurrentVersion\Devices
	Microsoft.Win32.RegistryKey mySystemPrinters = 
		Microsoft.Win32.Registry.Users.OpenSubKey(@".DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\Devices");
	foreach (String defaultPrinters in mySystemPrinters.GetValueNames()) 
	{
		cboDefaultPrinters.Items.Add(defaultPrinters); 
	}
	if (cboDefaultPrinters.Items.Count > 0) 
	{
		cboDefaultPrinters.SelectedIndex = 0;
	} 
	else 
	{
		rdoDefault.Enabled = false; 
	}
}

Don

Former Member
0 Kudos

Don,

I appreciate your reply. Suggesting a different SDK and redeveloping is expensive. I want proof that our current code will not work and is not supprted by SAP. If its a network/printer issue, we might be able to reconfigure our printers so that the printers are on the network but are dedicated for .net printing. That is not the case today.

0 Kudos

Hello,

Just to be clear, we do support the P2P API, we just won't fix any issues in it if there is a work around which is the OutPutController.

As one who escalates and works closely with our Program Managers and Developers I know that we will not be fixing the P2P API. As for documented, I don't believe we have any, I just know from experience working with them. We have a limited amount of resources and they would rather spend time on fixing the most popular Report Engine and API's.

Try a simple app to see if runs into the same issue, if it does I can get the Controller fixed.

Using/Converting to RAS is not that much more coding time. you can mix and match both engines. They are distributed so no extra overhead.

To get you going add these to your project:


using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.ReportDefModel;
using CrystalDecisions.ReportAppServer.CommonControls;
using CrystalDecisions.ReportAppServer.CommLayer;
using CrystalDecisions.ReportAppServer.CommonObjectModel;
using CrystalDecisions.ReportAppServer.ObjectFactory;
using CrystalDecisions.ReportAppServer.DataSetConversion;
using CrystalDecisions.ReportAppServer.DataDefModel;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;

namespace Unmanaged_RAS10_CSharp_Printers
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class frmMain : System.Windows.Forms.Form
	{
        CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;

...

Then in the open method in your app simply assign the rpt to client doc:

private void btnOpenReport_Click(object sender, System.EventArgs e)

{

rptClientDoc = new CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument(); // ReportClientDocumentClass();

...

rpt.Load(rptName.ToString(), OpenReportMethod.OpenReportByTempCopy);

rptClientDoc = rpt.ReportClientDocument;

...

{code}

Then in your print routine use the rptClientDoc, the rest of your app can stay as is...

The other advantage of using both is for scalability. The Engine is the "Basic" version, InProc RAS is the next step and then with a few more lines of code you can move to an OEM Build of standalone RAS Service called CR Server Embedded (CRSE), you can have multiple RAS services running and in a round robin configuration pass report processing to multiple RAS servers on one or more PC's. Then for absolute Report Processing power you can then move to the Full BOE Server where you can use either RAS or the Job Server to process the reports.

Thanks again

Don

Former Member
0 Kudos

Don,

I will look at this and hopefully it is as you describe. As you know, I do have web applications that are using the P2P. If I can take that report and print with the RAS SDK then great. The Web project is in VB so I should be able to translate from c#. It looks like I will be using the unmanaged RAS Server. This will work on my IIS 6 machine as is? I don't want to port to a BOE server due to other deployment requirements from my IIS Server. My steps are basic....

1. Open the report. (programatically,back end only, no user looks at the report)

2. Bind the data.

3. Print the report.

4. Close the report.

5 Dispose of the object.

I will look at yoru samples, the sample provided from SAP support and the Developer Library online URL. I don't know if I need new dll's for the RAS SDK vs the CR .Net SDIK.

Former Member
0 Kudos

Don,

Thank you very much for getting involved. It seems that SAP support is reiterating what you say here. I was able to get a print request to work with the new class object. The VB code is below.

I will move this working test application into our staging and production environments with the old code still there. This test application will be invoked after we go into "invalid printer specified" mode. One last question. Have you had issues with the class??????? Thanks..

OrptTCF.Load()

OrptTCF.SetParameterValue("RefundType", Me.RadioButtonList1.SelectedValue)

OrptTCF.SetParameterValue("PersonalPropertyTaxDueNow", Me.txtPPTDueNow.Text)

OrptTCF.SetParameterValue("RefundGrossAmount", Me.txtGrossRefund.Text)

OrptTCF.SetParameterValue("ContractNumber", Me.txtContractNo.Text)

OrptTCF.SetParameterValue("RefundCompany", Me.RadioButtonList2.SelectedValue)

OrptTCF.SetParameterValue("LateCharges", Me.txtLate.Text)

OrptTCF.SetParameterValue("OtherLabel", Me.txtOtherLabel.Text)

OrptTCF.SetParameterValue("OtherCharges", Me.txtOther.Text)

Dim raspropts As New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions

raspropts.PrinterName = "Kohler"

raspropts.PaperSize = CrystalDecisions.ReportAppServer.ReportDefModel.CrPaperSizeEnum.crPaperSizeDefault

raspropts.PrinterDuplex = CrystalDecisions.ReportAppServer.ReportDefModel.CrPrinterDuplexEnum.crPrinterDuplexDefault

raspropts.NumberOfCopies = 1

raspropts.Collated = False

raspropts.JobTitle = "none"

Dim rptClientdoc As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument

rptClientdoc = OrptTCF.ReportClientDocument

rptClientdoc.PrintOutputController.PrintReport(raspropts)

OrptTCF.Close()

OrptTCF.Dispose()

0 Kudos

Hi Patrick,

No new dll's to deploy, assuming you used one of our redist files to install CR on the WEB server they are included, just add them to your project and then at the top of the VB file and then it should work for you. All full versions of CR have inProc Ras available and you are fully licensed to use it.

Here's a link to [Licensing explained|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/24199] [original link is broken] [original link is broken];.

Your application looks relatively simple so it should not affect anything by changing the Print Routine.

For more info go to help.sap.com and find the RAS and .NET SDK help files and throw them on your Desktop for easy reference.

And yes it's easier to convert to VB from C# and there are sample app's that will do it for you also.

And IIS 6 is fully supported, here's the [platforms |http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/30da6fbd-7d4f-2d10-a38c-96596304586b]link.

Thanks again

Don

Former Member
0 Kudos

Don,

Well we got our invalid printer message today in our production application. I immediately ran the same code in our new application(that worked yesterday) and received the error below. Is there any history on this? I will post on my SAP support ticket as well. Thank your for looking at this.

Event code: 3005

Event message: An unhandled exception has occurred.

Event time: 1/25/2012 8:16:38 AM

Event time (UTC): 1/25/2012 2:16:38 PM

Event ID: 6aafbbbb72e74f7696149ef401da95bf

Event sequence: 6

Event occurrence: 1

Event detail code: 0

Application information:

Application domain: /LM/W3SVC/729091950/Root/NewCrystalReportPrinting-3-129719745889663000

Trust level: Full

Application Virtual Path: /NewCrystalReportPrinting

Application Path: D:\NewCrystalReportPrinting\

Machine name: MTKPORTAL

Process information:

Process ID: 5192

Process name: w3wp.exe

Account name: MTKPORTAL\ASPNET

Exception information:

Exception type: COMException

Exception message: Error HRESULT E_FAIL has been returned from a call to a COM component.

Request information:

Request URL: http://localhost:86/NewCrystalReportPrinting/WebForm1.aspx

Request path: /NewCrystalReportPrinting/WebForm1.aspx

User host address: 127.0.0.1

User: LWH\boorpd

Is authenticated: True

Authentication Type: NTLM

Thread account name: MTKPORTAL\ASPNET

Thread information:

Thread ID: 1

Thread account name: MTKPORTAL\ASPNET

Is impersonating: False

Stack trace: at CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.PrintReport(PrintReportOptions options)

at NewCrystalReportPrinting.WebForm1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\boorpd\My Documents\Visual Studio 2008\Projects\NewCrystalReportPrinting\NewCrystalReportPrinting\WebForm1.aspx.vb:line 188

at System.Web.UI.WebControls.Button.OnClick(EventArgs e)

at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)

at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Custom event details:

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

0 Kudos

Hi Patrick,

I'm curious, when you say you immediately ran the new code how would that "fix" the error? At that point IIS or the Printer Spooler has been corrupted so trying to send anything new will fail also. Although it does show that it's not CR causing the problem.

Can you use the new code rather than jumping into it when the original fails? All you are doing is compounding the issue.

This may suggest the issue is with the memory available in the printer itself... If it's busy nothing will print. Next time this happens see if anyone can send a print job say from a word doc or note etc.... anything outside of your app but on that PC. Or if it's a network printer then from any PC.

Have you ever used DebugDiag? You can set it for IIS Dumps, not sure if it will generate a dump for the printer issue though.

Here's another possible way to capture the issue: http://memprofiler.com/

If it's memory or handle leaks causing the issue this tool or something like it may be able to point to the cause. It may show where the issue is, print driver or network card etc....

It may even be in IIS, have you contacted Microsoft to get one of their Engineers to debug IIS? Could be a Contiguous Memory space issue causing the problem, no memory then no space for the P2P API to call the Print driver and that would pass the error message through to CR runtime.

Don

0 Kudos

Also,

HP Printers have been a baine for CR as long as I can remember ( CR 5 days ) Various memory leaks in their drivers, wrong memory space allocations in the DMExtra of the DEVMODE structure... The list goes on....

One thing I do know is if you do have multiple HP Print Drivers installed they can cause problems. What I have always recommended and from feed back is to uninstall all printers and when the option pops up to remove the driver then do so. Then install one driver that supports them all if possible, sometimes HP has a common driver that works for multiple printers. I believe what was happening was HP itself was cross loading their own dependencies, side by side compatibility issues.

Do you have a Print Server or is this 2003 Server also the print Server? If not can you create one, get all but one printer off that WEB Server.

Thanks again

Don

Former Member
0 Kudos

Don,

I have the new coding changes going in tonight. I get the feeling from your last post that the code is not the problem? If we were having a memory or handle leak with the old P2P, will we have the same with your new RAS object model?

Our printers are defined locally. They are attached to a print server but we did a trace and all the print is spooled directly to the printer. When we name the prnter, we do not include the print server. We install locally and name it as such.

There are a variety of printers on the web server. One day I assigned the universal print driver to all of the printers and still had the same issue. I did not go through the old print drivers and uninstall.

I am up for any recommendation. I would like your gut opinion on whether you think we are still going to see memory/leak issues......

Patrick

0 Kudos

Hi Patrick,

At this point it's hard to say for sure. CR is dynamic in a lot of it's functions, meaning we query the various parts to load the info from for our use. It could be that P2P is dynamically getting the info from the Printer each time or through Windows API's and the API P2P uses could be different, and like is, which explains why one works and one doesn't.

Tonights test may confirm this... If it's P2P causing/accessing invalid memory pointers or handles etc...

The more logs the better. Memory issues are a pain to debug, it can be related to Resources or third party applications, even AV software can suddenly block access because of high memory usage. Symantec dose this when I have VM-ware running, it pop's up a warning there is high disk usage and I have to allow it or funny things start happening.

IIS isn't clear of Memory issues either so it may be IIS causing the issue.

When you said you had to re-boot the server a few times to make it work suggests it's something outside of CR causing the problem but makes no sense either.... It also makes no sense why you could change the user but then lost that ability.... Could be something left over in the \temp folders interfering with the functions...

Next time you have to reboot and before starting up anything stop IIS, go into the \temp folders and delete everything that isn't locked. Then start up IIS and anything else that typically starts up.

Can you describe where all of the various parts are again? Is everything on the one Server, IIS, Application, Printer/Print Server.

I think also you said the app is running in it's own 32 bit App Pool also correct? If not please do so so it gets in it's own memory space.

If you can test this try this: One way to test if it's a onboard printer memory issue is to create a new Printer and set the port to file. This will generate multiple PRN files and you would have to print each one if this is production. But of course this won't work if you can't replicate on demand..... mmmmm but if you have a test box and you can get multiple users to hit it as a test that may help also.

Anything interesting in the IIS logs when this happens?

How many NIC cards do you have on that Server and are they Bridged? Could be a buffer issue there or could even be one on your local Router or Switch box also... Firewall logs may be another place to look could be the firewall is denying access also.

You'll actually always see memory leaks, MS is nortorious for little leaks, it's the big ones or the one that grow big and never get released that are of concern.

Anyways, see what happens tonight after changing your source to use the Controller.

Don

Former Member
0 Kudos

Don,

We are going to open an issue with Microsoft. Same issue different message. We are able to do a test print or notepad print to the printer.

Do you know if the .aspnet code for the crystal calls can run in 64bit mode? That maybe our next move. Currently everything runs in 32bit mode on a 64 bit server. What do you think and please point me in any direction.

Just a fyi that this failed immediately after a restart of the server. That adds to the fire.....

Patrick

0 Kudos

Hi Patrick,

CR 2008 is 32 bit only, it can run on a 64 bit OS but the App Pool must also be running in 32 bit mode.

Make sure the Printer driver is also 32 bit or that their 64 bit driver also supports 32 bit applications.

You may want open a call with HP also, possibly they can help debug the issue.

Don

Former Member
0 Kudos

Don,

I want to understand your Printer recommendations. I like your idea of having one print driver on our web server.

We have 6 printers defined locally on the Web Server that is hosting IIS. They all have different print drivers. There are a number of print drivers installed on the web server. The default printer is one of the six used for IIS printing.

Although I have made all of the print drivers the same(except the default printer), I have not uninstalled all of the print drivers.

With your rcommendation, I would have one print driver(universal) for all printers and uninstall of the unused print drivers.

Does it matter what driver is used on the Web Print Server? This is not local IIS server but a dedicated web print server. Does it matter what drivers are there?

Also, if we still have issues going forward, I do want to leap to IIS 7.0 and run this in a 64bit environment. I think our ASP calls to the Crystal Runtime in an IIS 64 bit application pool would be supported. I just wanted you to confirm this.

I am also hoping to call Microsoft this afternoon on any recommdation they might have on IIS printing for our Crystal Web applications. Thank you for your support.

0 Kudos

Hi Patrick,

I took the case over from Bhushan and will give you a call to discuss...

Thanks

Don

Answers (0)