This problem is solved.
The Vista computer in question would print documents using other applications, but wouldn't print documents using my application. Therefore I didn't think there was a problem with the print drivers. Microsoft suggested that the problem might be print drivers and a friend with a lot of PC experience suggested that the problem might be print drivers also.
If anyone else is getting the error in question on aPrintDialog, tell them to reinstall their print driverseven if they can print with other applications.
I reinstalled the print drivers and the problem is no longer a problem.
I would like to thank the person who responded to myproblem post.
G. Hackbart
I have a strange issue with a Visual Studio .net 2008 distributable windows forms application.
The printing does not work on my Clients computers who have a Vista OS. All of my clients get the following error when they try to print any form from a Vista operating system.
The PrintDialog comes up, the Client Clicks on OK to print and the following error is generated. The following exception is caught and the program gets no farther in the code. The program errors off in the PrintDialog.
Programmed error �An Error occurred printing the report�/font>
System Generated error �“Attempting to read or write protected memory. This is often an indication that other memory is corrupt�
Note - I am using the following code to print windows forms. I get the above error on any Vista computer except mine.The above application prints and runs ok on my computer which has a Vista OS. The application also prints and runs ok on Windows XP operating systems.
I have Visual Studio 2008 installed, Visual Studio 2003 installed and VB 6.0 installed on my vista computer. I have been printing VB forms with code similar to this for about 8 years.
I'm not sure why the program doesn't get past the PrintDialog on my clientvista computers.Are myvisual Studio security setting screwed up?
Any help would be greatly appreciated!!!
The Print code follows.
| SubDo_Print() |
|
| Try |
| DimdlgAsNewPrintDialog |
| dlg.Document=pd |
| DimresultAsDialogResult=dlg.ShowDialog() |
|
| If(result=System.Windows.Forms.DialogResult.OK)Then |
| DimpsDlgAsNewPageSetupDialog |
| psDlg.PageSettings=NewPageSettings |
|
| Ifresult=DialogResult.OKThen |
|
| pd.Print() |
|
| EndIf |
| EndIf |
|
| CatchexAsException |
| MessageBox.Show("Anerroroccurredprintingthereport-"+ex.Message) |
| EndTry |
|
| EndSub |
|
| |
| PrivateSubpd_PrintPage(ByValsenderAsObject,ByValevAs |
| System.Drawing.Printing.PrintPageEventArgs)Handlespd.PrintPage |
|
| CaptureForm() |
| imgBuffer.RotateFlip(RotateFlipType.Rotate90FlipXY) |
| ev.Graphics.DrawImage(imgBuffer,0,0) |
| |
| EndSub |
|
| |
|
| PrivateSubCaptureForm() |
|
| DimhResAsLong |
| DimhdcAsIntPtr |
| DimgraphicAsGraphics=Me.CreateGraphics |
| imgBuffer=NewBitmap(1000,1000,graphic) |
| DimimgImageAsGraphics=Drawing.Graphics.FromImage(imgBuffer) |
| imgImage.FillRectangle(NewSolidBrush(Me.BackColor),0,0,imgBuffer.Width,imgBuffer.Height) |
| hdc=imgImage.GetHdc() |
|
| frmpincome.DefInstance.AutoScrollPosition=NewPoint(0,0) |
| hRes=SendMessage(frmpincome.DefInstance.Handle,NewIntPtr(WM_Print),hdc,NewIntPtr(PRF_CHILDREN+PRF_CLIENT+PRF_OWNED)) |
| imgImage.ReleaseHdc(hdc) |
|
| EndSub |
|