Printing Problem
Ok,
I have been banging my head off the wall over this for about 2 hours and I can not figure out what is going on. I have a windows application that I need to be able to print from, no big deal. I set up my menus and such that are related to printing and calling:
[printdocument].Print();
Sends the document to the printer without a problem. Now if i do something like this:
PrintDocument tmpDoc = new PrintDocument();
tmpDoc.PrintPage += new PrintPageEventHandler(toPrinter);
tmpDoc.DefaultPageSettings = pgSettings;
PrintDialog dlg = new PrintDialog();
dlg.Document = tmpDoc;
DialogResult dlgResult = dlg.ShowDialog();
if (dlgResult == DialogResult.OK)
{
tmpDoc.Print();
}
The print Dialog box is displayed correctly BUT when the I click on the OK button, this line:
DialogResult dlgResult = dlg.ShowDialog();
Generates the error:
An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
Additional information: Request for the permission of type System.Drawing.Printing.PrintingPermission, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a failed.
As I said, calling [printdocument].print(); works fine and the page is printed correctly, however if i try to do anything else (change settings in code, or to use the dialog box) i get that error. Does anyone have any answers for this!?
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click  on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
|