Connecting Tech Pros Worldwide Help | Site Map

Safe Printing

Jody Gelowitz
Guest
 
Posts: n/a
#1: Nov 22 '05
I am trying to find the definition of "Safe Printing" and cannot find out
exactly what this entitles. The reason is that I am trying to print
contents from a single textbox to no avail using the PrintDialog control
under a security setting with only SafePrinting allowed.

I have attached a sample project that I am using to try to accomplish this.
The print dialog appears, but when I press the Print button, I get an
exception (at the end of this message). Any ideas how I can make this work?

Thanks,
Jody


System.Security.SecurityException: Request for the permission of type
System.Drawing.Printing.PrintingPermission, System.Drawing,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a failed.
at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr hdevmode)
at System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG data,
PrinterSettings settings, PageSettings pageSettings)
at System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog()
at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
RegexAssembly4_0
Assembly Version: 0.0.0.0
Win32 Version: n/a
CodeBase:
----------------------------------------
IEExecRemote
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll
----------------------------------------
PrintTest
Assembly Version: 1.0.1468.23656
Win32 Version: n/a
CodeBase: http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 7.0.5000.0
Win32 Version: 7.10.3052.4
CodeBase:
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.




Ken Tucker [MVP]
Guest
 
Posts: n/a
#2: Nov 22 '05

re: Safe Printing


Jody,

I can not access your sample code. Could you please post a link to
or email me your code.

Ken
----------------
"Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...[color=blue]
>I am trying to find the definition of "Safe Printing" and cannot find out
> exactly what this entitles. The reason is that I am trying to print
> contents from a single textbox to no avail using the PrintDialog control
> under a security setting with only SafePrinting allowed.
>
> I have attached a sample project that I am using to try to accomplish
> this.
> The print dialog appears, but when I press the Print button, I get an
> exception (at the end of this message). Any ideas how I can make this
> work?
>
> Thanks,
> Jody
>
>
> System.Security.SecurityException: Request for the permission of type
> System.Drawing.Printing.PrintingPermission, System.Drawing,
> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> failed.
> at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
> grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
> PermissionToken permToken)
> at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
> permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
> checkFrames, Int32 unrestrictedOverride)
> at System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
> cap, StackCrawlMark& stackMark)
> at System.Security.CodeAccessPermission.Demand()
> at System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr hdevmode)
> at System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG data,
> PrinterSettings settings, PageSettings pageSettings)
> at System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
> at System.Windows.Forms.CommonDialog.ShowDialog()
> at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
> at System.Windows.Forms.Control.OnClick(EventArgs e)
> at System.Windows.Forms.Button.OnClick(EventArgs e)
> at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> button, Int32 clicks)
> at System.Windows.Forms.Control.WndProc(Message& m)
> at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> at System.Windows.Forms.Button.WndProc(Message& m)
> at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
> at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
> at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
> IntPtr wparam, IntPtr lparam)
>
>
> ************** Loaded Assemblies **************
> mscorlib
> Assembly Version: 1.0.5000.0
> Win32 Version: 1.1.4322.573
> CodeBase:
> file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
> ----------------------------------------
> System.Drawing
> Assembly Version: 1.0.5000.0
> Win32 Version: 1.1.4322.573
> CodeBase:
> file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
> ----------------------------------------
> System
> Assembly Version: 1.0.5000.0
> Win32 Version: 1.1.4322.573
> CodeBase:
> file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
> ----------------------------------------
> RegexAssembly4_0
> Assembly Version: 0.0.0.0
> Win32 Version: n/a
> CodeBase:
> ----------------------------------------
> IEExecRemote
> Assembly Version: 1.0.5000.0
> Win32 Version: 1.1.4322.573
> CodeBase:
> file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll
> ----------------------------------------
> PrintTest
> Assembly Version: 1.0.1468.23656
> Win32 Version: n/a
> CodeBase: http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
> ----------------------------------------
> System.Windows.Forms
> Assembly Version: 1.0.5000.0
> Win32 Version: 1.1.4322.573
> CodeBase:
> file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
> ----------------------------------------
> System.Xml
> Assembly Version: 1.0.5000.0
> Win32 Version: 1.1.4322.573
> CodeBase:
> file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
> ----------------------------------------
> Microsoft.VisualBasic
> Assembly Version: 7.0.5000.0
> Win32 Version: 7.10.3052.4
> CodeBase:
> file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
> ----------------------------------------
>
> ************** JIT Debugging **************
> To enable just in time (JIT) debugging, the config file for this
> application or machine (machine.config) must have the
> jitDebugging value set in the system.windows.forms section.
> The application must also be compiled with debugging
> enabled.
>
>
>[/color]


Jody Gelowitz
Guest
 
Posts: n/a
#3: Nov 22 '05

re: Safe Printing


The code in question is as follows:

With dlgPrintSettings

If Not (.ShowDialog() = DialogResult.Cancel) Then

Try

TextBox1.AppendText("Printing ..." & ControlChars.CrLf)

..Document.Print()

TextBox1.AppendText("Print Successful")

Catch ex As Exception

Debug.WriteLine(ex.ToString)

'MsgBox(ex.ToString)

End Try

End If

End With



The security exception is thrown within the following line:

If Not (.ShowDialog() = DialogResult.Cancel) Then

after you click the PRINT button. The line below it never gets called:

TextBox1.AppendText("Printing ..." & ControlChars.CrLf)



Thanks,
Jody

"Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...[color=blue]
> Jody,
>
> I can not access your sample code. Could you please post a link[/color]
to[color=blue]
> or email me your code.
>
> Ken
> ----------------
> "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...[color=green]
> >I am trying to find the definition of "Safe Printing" and cannot find out
> > exactly what this entitles. The reason is that I am trying to print
> > contents from a single textbox to no avail using the PrintDialog control
> > under a security setting with only SafePrinting allowed.
> >
> > I have attached a sample project that I am using to try to accomplish
> > this.
> > The print dialog appears, but when I press the Print button, I get an
> > exception (at the end of this message). Any ideas how I can make this
> > work?
> >
> > Thanks,
> > Jody
> >
> >
> > System.Security.SecurityException: Request for the permission of type
> > System.Drawing.Printing.PrintingPermission, System.Drawing,
> > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> > failed.
> > at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
> > grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
> > PermissionToken permToken)
> > at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
> > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
> > checkFrames, Int32 unrestrictedOverride)
> > at System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
> > cap, StackCrawlMark& stackMark)
> > at System.Security.CodeAccessPermission.Demand()
> > at System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr[/color][/color]
hdevmode)[color=blue][color=green]
> > at System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG[/color][/color]
data,[color=blue][color=green]
> > PrinterSettings settings, PageSettings pageSettings)
> > at System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
> > at System.Windows.Forms.CommonDialog.ShowDialog()
> > at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
> > at System.Windows.Forms.Control.OnClick(EventArgs e)
> > at System.Windows.Forms.Button.OnClick(EventArgs e)
> > at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
> > at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> > button, Int32 clicks)
> > at System.Windows.Forms.Control.WndProc(Message& m)
> > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> > at System.Windows.Forms.Button.WndProc(Message& m)
> > at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
> > at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
> > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
> > IntPtr wparam, IntPtr lparam)
> >
> >
> > ************** Loaded Assemblies **************
> > mscorlib
> > Assembly Version: 1.0.5000.0
> > Win32 Version: 1.1.4322.573
> > CodeBase:
> > file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
> > ----------------------------------------
> > System.Drawing
> > Assembly Version: 1.0.5000.0
> > Win32 Version: 1.1.4322.573
> > CodeBase:
> >[/color][/color]
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[color=blue][color=green]
> > ----------------------------------------
> > System
> > Assembly Version: 1.0.5000.0
> > Win32 Version: 1.1.4322.573
> > CodeBase:
> >[/color][/color]
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[color=blue][color=green]
> > ----------------------------------------
> > RegexAssembly4_0
> > Assembly Version: 0.0.0.0
> > Win32 Version: n/a
> > CodeBase:
> > ----------------------------------------
> > IEExecRemote
> > Assembly Version: 1.0.5000.0
> > Win32 Version: 1.1.4322.573
> > CodeBase:
> >[/color][/color]
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll[color=blue][color=green]
> > ----------------------------------------
> > PrintTest
> > Assembly Version: 1.0.1468.23656
> > Win32 Version: n/a
> > CodeBase: http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
> > ----------------------------------------
> > System.Windows.Forms
> > Assembly Version: 1.0.5000.0
> > Win32 Version: 1.1.4322.573
> > CodeBase:
> >[/color][/color]
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[color=blue][color=green]
> > ----------------------------------------
> > System.Xml
> > Assembly Version: 1.0.5000.0
> > Win32 Version: 1.1.4322.573
> > CodeBase:
> >[/color][/color]
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll[color=blue][color=green]
> > ----------------------------------------
> > Microsoft.VisualBasic
> > Assembly Version: 7.0.5000.0
> > Win32 Version: 7.10.3052.4
> > CodeBase:
> >[/color][/color]
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll[color=blue][color=green]
> > ----------------------------------------
> >
> > ************** JIT Debugging **************
> > To enable just in time (JIT) debugging, the config file for this
> > application or machine (machine.config) must have the
> > jitDebugging value set in the system.windows.forms section.
> > The application must also be compiled with debugging
> > enabled.
> >
> >
> >[/color]
>
>[/color]


Ken Tucker [MVP]
Guest
 
Posts: n/a
#4: Nov 22 '05

re: Safe Printing


Hi,

Try this code. Do you get any errors ?

'Check to see if we have printing rights

Dim Allperm As Security.IPermission = New
Drawing.Printing.PrintingPermission(Drawing.Printi ng.PrintingPermissionLevel.AllPrinting)

Dim Defaultperm As Security.IPermission = New
Drawing.Printing.PrintingPermission(Drawing.Printi ng.PrintingPermissionLevel.DefaultPrinting)

Dim Safeperm As Security.IPermission = New
Drawing.Printing.PrintingPermission(Drawing.Printi ng.PrintingPermissionLevel.SafePrinting)

Try

Allperm.Demand()

Defaultperm.Demand()

Safeperm.Demand()

Catch ex As Exception

MessageBox.Show(ex.ToString)

End Try



Ken
----------------------
"Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
news:%23mFecRk1DHA.4032@tk2msftngp13.phx.gbl...[color=blue]
> The code in question is as follows:
>
> With dlgPrintSettings
>
> If Not (.ShowDialog() = DialogResult.Cancel) Then
>
> Try
>
> TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
>
> .Document.Print()
>
> TextBox1.AppendText("Print Successful")
>
> Catch ex As Exception
>
> Debug.WriteLine(ex.ToString)
>
> 'MsgBox(ex.ToString)
>
> End Try
>
> End If
>
> End With
>
>
>
> The security exception is thrown within the following line:
>
> If Not (.ShowDialog() = DialogResult.Cancel) Then
>
> after you click the PRINT button. The line below it never gets called:
>
> TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
>
>
>
> Thanks,
> Jody
>
> "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...[color=green]
>> Jody,
>>
>> I can not access your sample code. Could you please post a link[/color]
> to[color=green]
>> or email me your code.
>>
>> Ken
>> ----------------
>> "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
>> news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...[color=darkred]
>> >I am trying to find the definition of "Safe Printing" and cannot find
>> >out
>> > exactly what this entitles. The reason is that I am trying to print
>> > contents from a single textbox to no avail using the PrintDialog
>> > control
>> > under a security setting with only SafePrinting allowed.
>> >
>> > I have attached a sample project that I am using to try to accomplish
>> > this.
>> > The print dialog appears, but when I press the Print button, I get an
>> > exception (at the end of this message). Any ideas how I can make this
>> > work?
>> >
>> > Thanks,
>> > Jody
>> >
>> >
>> > System.Security.SecurityException: Request for the permission of type
>> > System.Drawing.Printing.PrintingPermission, System.Drawing,
>> > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
>> > failed.
>> > at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
>> > grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
>> > PermissionToken permToken)
>> > at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
>> > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark,
>> > Int32
>> > checkFrames, Int32 unrestrictedOverride)
>> > at
>> > System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
>> > cap, StackCrawlMark& stackMark)
>> > at System.Security.CodeAccessPermission.Demand()
>> > at System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr[/color][/color]
> hdevmode)[color=green][color=darkred]
>> > at System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG[/color][/color]
> data,[color=green][color=darkred]
>> > PrinterSettings settings, PageSettings pageSettings)
>> > at System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
>> > at System.Windows.Forms.CommonDialog.ShowDialog()
>> > at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
>> > at System.Windows.Forms.Control.OnClick(EventArgs e)
>> > at System.Windows.Forms.Button.OnClick(EventArgs e)
>> > at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
>> > at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
>> > button, Int32 clicks)
>> > at System.Windows.Forms.Control.WndProc(Message& m)
>> > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
>> > at System.Windows.Forms.Button.WndProc(Message& m)
>> > at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
>> > at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
>> > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
>> > IntPtr wparam, IntPtr lparam)
>> >
>> >
>> > ************** Loaded Assemblies **************
>> > mscorlib
>> > Assembly Version: 1.0.5000.0
>> > Win32 Version: 1.1.4322.573
>> > CodeBase:
>> > file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
>> > ----------------------------------------
>> > System.Drawing
>> > Assembly Version: 1.0.5000.0
>> > Win32 Version: 1.1.4322.573
>> > CodeBase:
>> >[/color][/color]
> file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[color=green][color=darkred]
>> > ----------------------------------------
>> > System
>> > Assembly Version: 1.0.5000.0
>> > Win32 Version: 1.1.4322.573
>> > CodeBase:
>> >[/color][/color]
> file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[color=green][color=darkred]
>> > ----------------------------------------
>> > RegexAssembly4_0
>> > Assembly Version: 0.0.0.0
>> > Win32 Version: n/a
>> > CodeBase:
>> > ----------------------------------------
>> > IEExecRemote
>> > Assembly Version: 1.0.5000.0
>> > Win32 Version: 1.1.4322.573
>> > CodeBase:
>> >[/color][/color]
> file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll[color=green][color=darkred]
>> > ----------------------------------------
>> > PrintTest
>> > Assembly Version: 1.0.1468.23656
>> > Win32 Version: n/a
>> > CodeBase: http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
>> > ----------------------------------------
>> > System.Windows.Forms
>> > Assembly Version: 1.0.5000.0
>> > Win32 Version: 1.1.4322.573
>> > CodeBase:
>> >[/color][/color]
> file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[color=green][color=darkred]
>> > ----------------------------------------
>> > System.Xml
>> > Assembly Version: 1.0.5000.0
>> > Win32 Version: 1.1.4322.573
>> > CodeBase:
>> >[/color][/color]
> file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll[color=green][color=darkred]
>> > ----------------------------------------
>> > Microsoft.VisualBasic
>> > Assembly Version: 7.0.5000.0
>> > Win32 Version: 7.10.3052.4
>> > CodeBase:
>> >[/color][/color]
> file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll[color=green][color=darkred]
>> > ----------------------------------------
>> >
>> > ************** JIT Debugging **************
>> > To enable just in time (JIT) debugging, the config file for this
>> > application or machine (machine.config) must have the
>> > jitDebugging value set in the system.windows.forms section.
>> > The application must also be compiled with debugging
>> > enabled.
>> >
>> >
>> >[/color]
>>
>>[/color]
>
>[/color]


Shel Blauman [MSFT]
Guest
 
Posts: n/a
#5: Nov 22 '05

re: Safe Printing


Here's the permission requirements I get when I check your application:

<IPermission class="System.Security.Permissions.EnvironmentPerm ission,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Security.Permissions.FileIOPermissio n, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Security.Permissions.SecurityPermiss ion,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Flags="UnmanagedCode, ControlEvidence"/>
<IPermission class="System.Security.Permissions.UIPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Net.WebPermission, System, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>

================================================== ==========================
====
Shel
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
news:%23mFecRk1DHA.4032@tk2msftngp13.phx.gbl...[color=blue]
> The code in question is as follows:
>
> With dlgPrintSettings
>
> If Not (.ShowDialog() = DialogResult.Cancel) Then
>
> Try
>
> TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
>
> .Document.Print()
>
> TextBox1.AppendText("Print Successful")
>
> Catch ex As Exception
>
> Debug.WriteLine(ex.ToString)
>
> 'MsgBox(ex.ToString)
>
> End Try
>
> End If
>
> End With
>
>
>
> The security exception is thrown within the following line:
>
> If Not (.ShowDialog() = DialogResult.Cancel) Then
>
> after you click the PRINT button. The line below it never gets called:
>
> TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
>
>
>
> Thanks,
> Jody
>
> "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...[color=green]
> > Jody,
> >
> > I can not access your sample code. Could you please post a link[/color]
> to[color=green]
> > or email me your code.
> >
> > Ken
> > ----------------
> > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > >I am trying to find the definition of "Safe Printing" and cannot find[/color][/color][/color]
out[color=blue][color=green][color=darkred]
> > > exactly what this entitles. The reason is that I am trying to print
> > > contents from a single textbox to no avail using the PrintDialog[/color][/color][/color]
control[color=blue][color=green][color=darkred]
> > > under a security setting with only SafePrinting allowed.
> > >
> > > I have attached a sample project that I am using to try to accomplish
> > > this.
> > > The print dialog appears, but when I press the Print button, I get an
> > > exception (at the end of this message). Any ideas how I can make this
> > > work?
> > >
> > > Thanks,
> > > Jody
> > >
> > >
> > > System.Security.SecurityException: Request for the permission of type
> > > System.Drawing.Printing.PrintingPermission, System.Drawing,
> > > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> > > failed.
> > > at[/color][/color][/color]
System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet[color=blue][color=green][color=darkred]
> > > grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
> > > PermissionToken permToken)
> > > at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
> > > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark,[/color][/color][/color]
Int32[color=blue][color=green][color=darkred]
> > > checkFrames, Int32 unrestrictedOverride)
> > > at[/color][/color][/color]
System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission[color=blue][color=green][color=darkred]
> > > cap, StackCrawlMark& stackMark)
> > > at System.Security.CodeAccessPermission.Demand()
> > > at System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr[/color][/color]
> hdevmode)[color=green][color=darkred]
> > > at System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG[/color][/color]
> data,[color=green][color=darkred]
> > > PrinterSettings settings, PageSettings pageSettings)
> > > at System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
> > > at System.Windows.Forms.CommonDialog.ShowDialog()
> > > at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
> > > at System.Windows.Forms.Control.OnClick(EventArgs e)
> > > at System.Windows.Forms.Button.OnClick(EventArgs e)
> > > at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
> > > at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> > > button, Int32 clicks)
> > > at System.Windows.Forms.Control.WndProc(Message& m)
> > > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> > > at System.Windows.Forms.Button.WndProc(Message& m)
> > > at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
> > > at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
> > > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32[/color][/color][/color]
msg,[color=blue][color=green][color=darkred]
> > > IntPtr wparam, IntPtr lparam)
> > >
> > >
> > > ************** Loaded Assemblies **************
> > > mscorlib
> > > Assembly Version: 1.0.5000.0
> > > Win32 Version: 1.1.4322.573
> > > CodeBase:
> > > file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
> > > ----------------------------------------
> > > System.Drawing
> > > Assembly Version: 1.0.5000.0
> > > Win32 Version: 1.1.4322.573
> > > CodeBase:
> > >[/color][/color]
>[/color]
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[color=blue][color=green][color=darkred]
> > > ----------------------------------------
> > > System
> > > Assembly Version: 1.0.5000.0
> > > Win32 Version: 1.1.4322.573
> > > CodeBase:
> > >[/color][/color]
>[/color]
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[color=blue][color=green][color=darkred]
> > > ----------------------------------------
> > > RegexAssembly4_0
> > > Assembly Version: 0.0.0.0
> > > Win32 Version: n/a
> > > CodeBase:
> > > ----------------------------------------
> > > IEExecRemote
> > > Assembly Version: 1.0.5000.0
> > > Win32 Version: 1.1.4322.573
> > > CodeBase:
> > >[/color][/color]
>[/color]
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll[color=blue][color=green][color=darkred]
> > > ----------------------------------------
> > > PrintTest
> > > Assembly Version: 1.0.1468.23656
> > > Win32 Version: n/a
> > > CodeBase: http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
> > > ----------------------------------------
> > > System.Windows.Forms
> > > Assembly Version: 1.0.5000.0
> > > Win32 Version: 1.1.4322.573
> > > CodeBase:
> > >[/color][/color]
>[/color]
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[color=blue][color=green][color=darkred]
> > > ----------------------------------------
> > > System.Xml
> > > Assembly Version: 1.0.5000.0
> > > Win32 Version: 1.1.4322.573
> > > CodeBase:
> > >[/color][/color]
>[/color]
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll[color=blue][color=green][color=darkred]
> > > ----------------------------------------
> > > Microsoft.VisualBasic
> > > Assembly Version: 7.0.5000.0
> > > Win32 Version: 7.10.3052.4
> > > CodeBase:
> > >[/color][/color]
>[/color]
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll[color=blue][color=green][color=darkred]
> > > ----------------------------------------
> > >
> > > ************** JIT Debugging **************
> > > To enable just in time (JIT) debugging, the config file for this
> > > application or machine (machine.config) must have the
> > > jitDebugging value set in the system.windows.forms section.
> > > The application must also be compiled with debugging
> > > enabled.
> > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Shel Blauman [MSFT]
Guest
 
Posts: n/a
#6: Nov 22 '05

re: Safe Printing


Let me admend this, you'll also need safe printing. Just to display the
dialog box you're going to need unrestricted UIPermission, then to perform
the printing you'll need the safe printing permission. Was able to run your
app to completion with safe printing permission. You may not need all the
other permissions I came up with, you might try experimenting.

Shel

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
news:e2A%23%23fk1DHA.1760@TK2MSFTNGP10.phx.gbl...[color=blue]
> Here's the permission requirements I get when I check your application:
>
> <IPermission class="System.Security.Permissions.EnvironmentPerm ission,
> mscorlib, Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089"
> version="1"
> Unrestricted="true"/>
> <IPermission class="System.Security.Permissions.FileIOPermissio n,[/color]
mscorlib,[color=blue]
> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> version="1"
> Unrestricted="true"/>
> <IPermission class="System.Security.Permissions.SecurityPermiss ion,
> mscorlib, Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089"
> version="1"
> Flags="UnmanagedCode, ControlEvidence"/>
> <IPermission class="System.Security.Permissions.UIPermission, mscorlib,
> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> version="1"
> Unrestricted="true"/>
> <IPermission class="System.Net.WebPermission, System, Version=1.0.5000.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089"
> version="1"
> Unrestricted="true"/>
>
>[/color]
================================================== ==========================[color=blue]
> ====
> Shel
> --
> This posting is provided "AS IS" with no warranties, and confers no[/color]
rights.[color=blue]
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
>
> "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> news:%23mFecRk1DHA.4032@tk2msftngp13.phx.gbl...[color=green]
> > The code in question is as follows:
> >
> > With dlgPrintSettings
> >
> > If Not (.ShowDialog() = DialogResult.Cancel) Then
> >
> > Try
> >
> > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> >
> > .Document.Print()
> >
> > TextBox1.AppendText("Print Successful")
> >
> > Catch ex As Exception
> >
> > Debug.WriteLine(ex.ToString)
> >
> > 'MsgBox(ex.ToString)
> >
> > End Try
> >
> > End If
> >
> > End With
> >
> >
> >
> > The security exception is thrown within the following line:
> >
> > If Not (.ShowDialog() = DialogResult.Cancel) Then
> >
> > after you click the PRINT button. The line below it never gets called:
> >
> > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> >
> >
> >
> > Thanks,
> > Jody
> >
> > "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> > news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Jody,
> > >
> > > I can not access your sample code. Could you please post a[/color][/color][/color]
link[color=blue][color=green]
> > to[color=darkred]
> > > or email me your code.
> > >
> > > Ken
> > > ----------------
> > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > > news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...
> > > >I am trying to find the definition of "Safe Printing" and cannot find[/color][/color]
> out[color=green][color=darkred]
> > > > exactly what this entitles. The reason is that I am trying to print
> > > > contents from a single textbox to no avail using the PrintDialog[/color][/color]
> control[color=green][color=darkred]
> > > > under a security setting with only SafePrinting allowed.
> > > >
> > > > I have attached a sample project that I am using to try to[/color][/color][/color]
accomplish[color=blue][color=green][color=darkred]
> > > > this.
> > > > The print dialog appears, but when I press the Print button, I get[/color][/color][/color]
an[color=blue][color=green][color=darkred]
> > > > exception (at the end of this message). Any ideas how I can make[/color][/color][/color]
this[color=blue][color=green][color=darkred]
> > > > work?
> > > >
> > > > Thanks,
> > > > Jody
> > > >
> > > >
> > > > System.Security.SecurityException: Request for the permission of[/color][/color][/color]
type[color=blue][color=green][color=darkred]
> > > > System.Drawing.Printing.PrintingPermission, System.Drawing,
> > > > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> > > > failed.
> > > > at[/color][/color]
> System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet[color=green][color=darkred]
> > > > grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
> > > > PermissionToken permToken)
> > > > at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
> > > > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark,[/color][/color]
> Int32[color=green][color=darkred]
> > > > checkFrames, Int32 unrestrictedOverride)
> > > > at[/color][/color]
> System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission[color=green][color=darkred]
> > > > cap, StackCrawlMark& stackMark)
> > > > at System.Security.CodeAccessPermission.Demand()
> > > > at System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr[/color]
> > hdevmode)[color=darkred]
> > > > at System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG[/color]
> > data,[color=darkred]
> > > > PrinterSettings settings, PageSettings pageSettings)
> > > > at System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
> > > > at System.Windows.Forms.CommonDialog.ShowDialog()
> > > > at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
> > > > at System.Windows.Forms.Control.OnClick(EventArgs e)
> > > > at System.Windows.Forms.Button.OnClick(EventArgs e)
> > > > at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
> > > > at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> > > > button, Int32 clicks)
> > > > at System.Windows.Forms.Control.WndProc(Message& m)
> > > > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> > > > at System.Windows.Forms.Button.WndProc(Message& m)
> > > > at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
> > > > at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
> > > > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32[/color][/color]
> msg,[color=green][color=darkred]
> > > > IntPtr wparam, IntPtr lparam)
> > > >
> > > >
> > > > ************** Loaded Assemblies **************
> > > > mscorlib
> > > > Assembly Version: 1.0.5000.0
> > > > Win32 Version: 1.1.4322.573
> > > > CodeBase:
> > > > file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
> > > > ----------------------------------------
> > > > System.Drawing
> > > > Assembly Version: 1.0.5000.0
> > > > Win32 Version: 1.1.4322.573
> > > > CodeBase:
> > > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[color=blue][color=green][color=darkred]
> > > > ----------------------------------------
> > > > System
> > > > Assembly Version: 1.0.5000.0
> > > > Win32 Version: 1.1.4322.573
> > > > CodeBase:
> > > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[color=blue][color=green][color=darkred]
> > > > ----------------------------------------
> > > > RegexAssembly4_0
> > > > Assembly Version: 0.0.0.0
> > > > Win32 Version: n/a
> > > > CodeBase:
> > > > ----------------------------------------
> > > > IEExecRemote
> > > > Assembly Version: 1.0.5000.0
> > > > Win32 Version: 1.1.4322.573
> > > > CodeBase:
> > > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll[color=blue][color=green][color=darkred]
> > > > ----------------------------------------
> > > > PrintTest
> > > > Assembly Version: 1.0.1468.23656
> > > > Win32 Version: n/a
> > > > CodeBase: http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
> > > > ----------------------------------------
> > > > System.Windows.Forms
> > > > Assembly Version: 1.0.5000.0
> > > > Win32 Version: 1.1.4322.573
> > > > CodeBase:
> > > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[color=blue][color=green][color=darkred]
> > > > ----------------------------------------
> > > > System.Xml
> > > > Assembly Version: 1.0.5000.0
> > > > Win32 Version: 1.1.4322.573
> > > > CodeBase:
> > > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll[color=blue][color=green][color=darkred]
> > > > ----------------------------------------
> > > > Microsoft.VisualBasic
> > > > Assembly Version: 7.0.5000.0
> > > > Win32 Version: 7.10.3052.4
> > > > CodeBase:
> > > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll[color=blue][color=green][color=darkred]
> > > > ----------------------------------------
> > > >
> > > > ************** JIT Debugging **************
> > > > To enable just in time (JIT) debugging, the config file for this
> > > > application or machine (machine.config) must have the
> > > > jitDebugging value set in the system.windows.forms section.
> > > > The application must also be compiled with debugging
> > > > enabled.
> > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Jody Gelowitz
Guest
 
Posts: n/a
#7: Nov 22 '05

re: Safe Printing


I tried the code that you gave, and here are the results:

Demand - Printing All: False
System.Security.SecurityException: Request for the permission of type
System.Drawing.Printing.PrintingPermission, System.Drawing,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a failed.
at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at PrintTest.Form1.Button1_Click(Object sender, EventArgs e) in
C:\Projects\WorkArea\PrintTest\Form1.vb:line 102

Demand - Printing Default: False
System.Security.SecurityException: Request for the permission of type
System.Drawing.Printing.PrintingPermission, System.Drawing,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a failed.
at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at PrintTest.Form1.Button1_Click(Object sender, EventArgs e) in
C:\Projects\WorkArea\PrintTest\Form1.vb:line 109

Demand - Printing Safe: True

Thanks,
Jody


"Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
news:e7T6Gck1DHA.3116@TK2MSFTNGP11.phx.gbl...[color=blue]
> Hi,
>
> Try this code. Do you get any errors ?
>
> 'Check to see if we have printing rights
>
> Dim Allperm As Security.IPermission = New
>[/color]
Drawing.Printing.PrintingPermission(Drawing.Printi ng.PrintingPermissionLevel
..AllPrinting)[color=blue]
>
> Dim Defaultperm As Security.IPermission = New
>[/color]
Drawing.Printing.PrintingPermission(Drawing.Printi ng.PrintingPermissionLevel
..DefaultPrinting)[color=blue]
>
> Dim Safeperm As Security.IPermission = New
>[/color]
Drawing.Printing.PrintingPermission(Drawing.Printi ng.PrintingPermissionLevel
..SafePrinting)[color=blue]
>
> Try
>
> Allperm.Demand()
>
> Defaultperm.Demand()
>
> Safeperm.Demand()
>
> Catch ex As Exception
>
> MessageBox.Show(ex.ToString)
>
> End Try
>
>
>
> Ken
> ----------------------
> "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> news:%23mFecRk1DHA.4032@tk2msftngp13.phx.gbl...[color=green]
> > The code in question is as follows:
> >
> > With dlgPrintSettings
> >
> > If Not (.ShowDialog() = DialogResult.Cancel) Then
> >
> > Try
> >
> > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> >
> > .Document.Print()
> >
> > TextBox1.AppendText("Print Successful")
> >
> > Catch ex As Exception
> >
> > Debug.WriteLine(ex.ToString)
> >
> > 'MsgBox(ex.ToString)
> >
> > End Try
> >
> > End If
> >
> > End With
> >
> >
> >
> > The security exception is thrown within the following line:
> >
> > If Not (.ShowDialog() = DialogResult.Cancel) Then
> >
> > after you click the PRINT button. The line below it never gets called:
> >
> > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> >
> >
> >
> > Thanks,
> > Jody
> >
> > "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> > news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...[color=darkred]
> >> Jody,
> >>
> >> I can not access your sample code. Could you please post a[/color][/color][/color]
link[color=blue][color=green]
> > to[color=darkred]
> >> or email me your code.
> >>
> >> Ken
> >> ----------------
> >> "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> >> news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...
> >> >I am trying to find the definition of "Safe Printing" and cannot find
> >> >out
> >> > exactly what this entitles. The reason is that I am trying to print
> >> > contents from a single textbox to no avail using the PrintDialog
> >> > control
> >> > under a security setting with only SafePrinting allowed.
> >> >
> >> > I have attached a sample project that I am using to try to accomplish
> >> > this.
> >> > The print dialog appears, but when I press the Print button, I get an
> >> > exception (at the end of this message). Any ideas how I can make[/color][/color][/color]
this[color=blue][color=green][color=darkred]
> >> > work?
> >> >
> >> > Thanks,
> >> > Jody
> >> >
> >> >
> >> > System.Security.SecurityException: Request for the permission of type
> >> > System.Drawing.Printing.PrintingPermission, System.Drawing,
> >> > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
> >> > failed.
> >> > at[/color][/color][/color]
System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet[color=blue][color=green][color=darkred]
> >> > grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
> >> > PermissionToken permToken)
> >> > at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
> >> > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark,
> >> > Int32
> >> > checkFrames, Int32 unrestrictedOverride)
> >> > at
> >> > System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
> >> > cap, StackCrawlMark& stackMark)
> >> > at System.Security.CodeAccessPermission.Demand()
> >> > at System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr[/color]
> > hdevmode)[color=darkred]
> >> > at System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG[/color]
> > data,[color=darkred]
> >> > PrinterSettings settings, PageSettings pageSettings)
> >> > at System.Windows.Forms.PrintDialog.RunDialog(IntPtr hwndOwner)
> >> > at System.Windows.Forms.CommonDialog.ShowDialog()
> >> > at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
> >> > at System.Windows.Forms.Control.OnClick(EventArgs e)
> >> > at System.Windows.Forms.Button.OnClick(EventArgs e)
> >> > at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
> >> > at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> >> > button, Int32 clicks)
> >> > at System.Windows.Forms.Control.WndProc(Message& m)
> >> > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> >> > at System.Windows.Forms.Button.WndProc(Message& m)
> >> > at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
> >> > at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
> >> > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32[/color][/color][/color]
msg,[color=blue][color=green][color=darkred]
> >> > IntPtr wparam, IntPtr lparam)
> >> >
> >> >
> >> > ************** Loaded Assemblies **************
> >> > mscorlib
> >> > Assembly Version: 1.0.5000.0
> >> > Win32 Version: 1.1.4322.573
> >> > CodeBase:
> >> > file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
> >> > ----------------------------------------
> >> > System.Drawing
> >> > Assembly Version: 1.0.5000.0
> >> > Win32 Version: 1.1.4322.573
> >> > CodeBase:
> >> >[/color]
> >[/color][/color]
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[color=blue][color=green][color=darkred]
> >> > ----------------------------------------
> >> > System
> >> > Assembly Version: 1.0.5000.0
> >> > Win32 Version: 1.1.4322.573
> >> > CodeBase:
> >> >[/color]
> >[/color][/color]
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[color=blue][color=green][color=darkred]
> >> > ----------------------------------------
> >> > RegexAssembly4_0
> >> > Assembly Version: 0.0.0.0
> >> > Win32 Version: n/a
> >> > CodeBase:
> >> > ----------------------------------------
> >> > IEExecRemote
> >> > Assembly Version: 1.0.5000.0
> >> > Win32 Version: 1.1.4322.573
> >> > CodeBase:
> >> >[/color]
> >[/color][/color]
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll[color=blue][color=green][color=darkred]
> >> > ----------------------------------------
> >> > PrintTest
> >> > Assembly Version: 1.0.1468.23656
> >> > Win32 Version: n/a
> >> > CodeBase: http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
> >> > ----------------------------------------
> >> > System.Windows.Forms
> >> > Assembly Version: 1.0.5000.0
> >> > Win32 Version: 1.1.4322.573
> >> > CodeBase:
> >> >[/color]
> >[/color][/color]
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[color=blue][color=green][color=darkred]
> >> > ----------------------------------------
> >> > System.Xml
> >> > Assembly Version: 1.0.5000.0
> >> > Win32 Version: 1.1.4322.573
> >> > CodeBase:
> >> >[/color]
> >[/color][/color]
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll[color=blue][color=green][color=darkred]
> >> > ----------------------------------------
> >> > Microsoft.VisualBasic
> >> > Assembly Version: 7.0.5000.0
> >> > Win32 Version: 7.10.3052.4
> >> > CodeBase:
> >> >[/color]
> >[/color][/color]
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll[color=blue][color=green][color=darkred]
> >> > ----------------------------------------
> >> >
> >> > ************** JIT Debugging **************
> >> > To enable just in time (JIT) debugging, the config file for this
> >> > application or machine (machine.config) must have the
> >> > jitDebugging value set in the system.windows.forms section.
> >> > The application must also be compiled with debugging
> >> > enabled.
> >> >
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]


Shel Blauman [MSFT]
Guest
 
Posts: n/a
#8: Nov 22 '05

re: Safe Printing


The only way I can get an Internet permission set equivalent to work is to
up the printing permissions to all. Doesn't work with safe.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
news:%238UyrJt1DHA.4060@TK2MSFTNGP11.phx.gbl...[color=blue]
> I am still having difficulty in getting this to work. I have attached an
> updated sample project with what I am trying to accomplish.
>
> The project will be run over the Internet Zone with the default security
> settings which have limited UIPermissions and SafePrinting. The[/color]
permissions[color=blue]
> that I have enforced on the project are listed below this message. One
> change that I had to do was to move the UIPermission from Minimal to
> Optional in order for the application to run over the Internet Zone.
>
> If somebody is able to get printing working with the permissions I have
> described, could you please provide some sample code as to how it was[/color]
done?[color=blue]
> I am not sure if I am just missing something small or if I am completely
> off-base with this. Having the print dialog is not a requirement for this
> if it violates the default security settings for the Internet Zone.
>
> Permissions on the Assembly:
> ------------------------------
> minimal permission set:
> <PermissionSet class="System.Security.PermissionSet"
> version="1">
> <IPermission class="System.Security.Permissions.SecurityPermiss ion,
> mscorlib, Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089"
> version="1"
> Flags="Execution"/>
> <IPermission class="System.Drawing.Printing.PrintingPermission,
> System.Drawing, Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a"
> version="1"
> Level="SafePrinting"/>
> </PermissionSet>
>
> optional permission set:
> <PermissionSet class="System.Security.PermissionSet"
> version="1">
> <IPermission class="System.Security.Permissions.UIPermission, mscorlib,
> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> version="1"
> Unrestricted="true"/>
> </PermissionSet>
>
> refused permission set:
> Not specified
>
>
>
>
>
> "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
> news:OBrh5tk1DHA.556@TK2MSFTNGP11.phx.gbl...[color=green]
> > Let me admend this, you'll also need safe printing. Just to display the
> > dialog box you're going to need unrestricted UIPermission, then to[/color][/color]
perform[color=blue][color=green]
> > the printing you'll need the safe printing permission. Was able to run[/color]
> your[color=green]
> > app to completion with safe printing permission. You may not need all[/color][/color]
the[color=blue][color=green]
> > other permissions I came up with, you might try experimenting.
> >
> > Shel
> >
> > --
> > This posting is provided "AS IS" with no warranties, and confers no[/color]
> rights.[color=green]
> > Use of included script samples are subject to the terms specified at
> > http://www.microsoft.com/info/cpyright.htm
> >
> >
> > "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
> > news:e2A%23%23fk1DHA.1760@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Here's the permission requirements I get when I check your[/color][/color][/color]
application:[color=blue][color=green][color=darkred]
> > >
> > > <IPermission class="System.Security.Permissions.EnvironmentPerm ission,
> > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > PublicKeyToken=b77a5c561934e089"
> > > version="1"
> > > Unrestricted="true"/>
> > > <IPermission class="System.Security.Permissions.FileIOPermissio n,[/color]
> > mscorlib,[color=darkred]
> > > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > > version="1"
> > > Unrestricted="true"/>
> > > <IPermission class="System.Security.Permissions.SecurityPermiss ion,
> > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > PublicKeyToken=b77a5c561934e089"
> > > version="1"
> > > Flags="UnmanagedCode, ControlEvidence"/>
> > > <IPermission class="System.Security.Permissions.UIPermission,[/color][/color][/color]
mscorlib,[color=blue][color=green][color=darkred]
> > > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > > version="1"
> > > Unrestricted="true"/>
> > > <IPermission class="System.Net.WebPermission, System,[/color][/color]
> Version=1.0.5000.0,[color=green][color=darkred]
> > > Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > > version="1"
> > > Unrestricted="true"/>
> > >
> > >[/color]
> >[/color]
>[/color]
================================================== ==========================[color=blue][color=green][color=darkred]
> > > ====
> > > Shel
> > > --
> > > This posting is provided "AS IS" with no warranties, and confers no[/color]
> > rights.[color=darkred]
> > > Use of included script samples are subject to the terms specified at
> > > http://www.microsoft.com/info/cpyright.htm
> > >
> > >
> > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > > news:%23mFecRk1DHA.4032@tk2msftngp13.phx.gbl...
> > > > The code in question is as follows:
> > > >
> > > > With dlgPrintSettings
> > > >
> > > > If Not (.ShowDialog() = DialogResult.Cancel) Then
> > > >
> > > > Try
> > > >
> > > > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> > > >
> > > > .Document.Print()
> > > >
> > > > TextBox1.AppendText("Print Successful")
> > > >
> > > > Catch ex As Exception
> > > >
> > > > Debug.WriteLine(ex.ToString)
> > > >
> > > > 'MsgBox(ex.ToString)
> > > >
> > > > End Try
> > > >
> > > > End If
> > > >
> > > > End With
> > > >
> > > >
> > > >
> > > > The security exception is thrown within the following line:
> > > >
> > > > If Not (.ShowDialog() = DialogResult.Cancel) Then
> > > >
> > > > after you click the PRINT button. The line below it never gets[/color][/color][/color]
called:[color=blue][color=green][color=darkred]
> > > >
> > > > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> > > >
> > > >
> > > >
> > > > Thanks,
> > > > Jody
> > > >
> > > > "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> > > > news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...
> > > > > Jody,
> > > > >
> > > > > I can not access your sample code. Could you please post[/color][/color][/color]
a[color=blue][color=green]
> > link[color=darkred]
> > > > to
> > > > > or email me your code.
> > > > >
> > > > > Ken
> > > > > ----------------
> > > > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > > > > news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...
> > > > > >I am trying to find the definition of "Safe Printing" and cannot[/color][/color]
> find[color=green][color=darkred]
> > > out
> > > > > > exactly what this entitles. The reason is that I am trying to[/color][/color]
> print[color=green][color=darkred]
> > > > > > contents from a single textbox to no avail using the PrintDialog
> > > control
> > > > > > under a security setting with only SafePrinting allowed.
> > > > > >
> > > > > > I have attached a sample project that I am using to try to[/color]
> > accomplish[color=darkred]
> > > > > > this.
> > > > > > The print dialog appears, but when I press the Print button, I[/color][/color][/color]
get[color=blue][color=green]
> > an[color=darkred]
> > > > > > exception (at the end of this message). Any ideas how I can[/color][/color][/color]
make[color=blue][color=green]
> > this[color=darkred]
> > > > > > work?
> > > > > >
> > > > > > Thanks,
> > > > > > Jody
> > > > > >
> > > > > >
> > > > > > System.Security.SecurityException: Request for the permission of[/color]
> > type[color=darkred]
> > > > > > System.Drawing.Printing.PrintingPermission, System.Drawing,
> > > > > > Version=1.0.5000.0, Culture=neutral,[/color][/color]
> PublicKeyToken=b03f5f7f11d50a3a[color=green][color=darkred]
> > > > > > failed.
> > > > > > at
> > > System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
> > > > > > grantedSet, PermissionSet deniedSet, CodeAccessPermission[/color][/color][/color]
demand,[color=blue][color=green][color=darkred]
> > > > > > PermissionToken permToken)
> > > > > > at[/color][/color]
> System.Security.CodeAccessSecurityEngine.Check(Per missionToken[color=green][color=darkred]
> > > > > > permToken, CodeAccessPermission demand, StackCrawlMark&[/color][/color][/color]
stackMark,[color=blue][color=green][color=darkred]
> > > Int32
> > > > > > checkFrames, Int32 unrestrictedOverride)
> > > > > > at
> > > System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
> > > > > > cap, StackCrawlMark& stackMark)
> > > > > > at System.Security.CodeAccessPermission.Demand()
> > > > > > at System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr
> > > > hdevmode)
> > > > > > at[/color][/color]
> System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG[color=green][color=darkred]
> > > > data,
> > > > > > PrinterSettings settings, PageSettings pageSettings)
> > > > > > at System.Windows.Forms.PrintDialog.RunDialog(IntPtr[/color][/color][/color]
hwndOwner)[color=blue][color=green][color=darkred]
> > > > > > at System.Windows.Forms.CommonDialog.ShowDialog()
> > > > > > at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
> > > > > > at System.Windows.Forms.Control.OnClick(EventArgs e)
> > > > > > at System.Windows.Forms.Button.OnClick(EventArgs e)
> > > > > > at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs[/color][/color][/color]
mevent)[color=blue][color=green][color=darkred]
> > > > > > at System.Windows.Forms.Control.WmMouseUp(Message& m,[/color][/color]
> MouseButtons[color=green][color=darkred]
> > > > > > button, Int32 clicks)
> > > > > > at System.Windows.Forms.Control.WndProc(Message& m)
> > > > > > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> > > > > > at System.Windows.Forms.Button.WndProc(Message& m)
> > > > > > at System.Windows.Forms.ControlNativeWindow.OnMessage (Message&[/color][/color]
> m)[color=green][color=darkred]
> > > > > > at System.Windows.Forms.ControlNativeWindow.WndProc(M essage&[/color][/color][/color]
m)[color=blue][color=green][color=darkred]
> > > > > > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,[/color][/color][/color]
Int32[color=blue][color=green][color=darkred]
> > > msg,
> > > > > > IntPtr wparam, IntPtr lparam)
> > > > > >
> > > > > >
> > > > > > ************** Loaded Assemblies **************
> > > > > > mscorlib
> > > > > > Assembly Version: 1.0.5000.0
> > > > > > Win32 Version: 1.1.4322.573
> > > > > > CodeBase:
> > > > > >[/color][/color][/color]
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll[color=blue][color=green][color=darkred]
> > > > > > ----------------------------------------
> > > > > > System.Drawing
> > > > > > Assembly Version: 1.0.5000.0
> > > > > > Win32 Version: 1.1.4322.573
> > > > > > CodeBase:
> > > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[color=blue][color=green][color=darkred]
> > > > > > ----------------------------------------
> > > > > > System
> > > > > > Assembly Version: 1.0.5000.0
> > > > > > Win32 Version: 1.1.4322.573
> > > > > > CodeBase:
> > > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[color=blue][color=green][color=darkred]
> > > > > > ----------------------------------------
> > > > > > RegexAssembly4_0
> > > > > > Assembly Version: 0.0.0.0
> > > > > > Win32 Version: n/a
> > > > > > CodeBase:
> > > > > > ----------------------------------------
> > > > > > IEExecRemote
> > > > > > Assembly Version: 1.0.5000.0
> > > > > > Win32 Version: 1.1.4322.573
> > > > > > CodeBase:
> > > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll[color=blue][color=green][color=darkred]
> > > > > > ----------------------------------------
> > > > > > PrintTest
> > > > > > Assembly Version: 1.0.1468.23656
> > > > > > Win32 Version: n/a
> > > > > > CodeBase:[/color][/color]
> http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE[color=green][color=darkred]
> > > > > > ----------------------------------------
> > > > > > System.Windows.Forms
> > > > > > Assembly Version: 1.0.5000.0
> > > > > > Win32 Version: 1.1.4322.573
> > > > > > CodeBase:
> > > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[color=blue][color=green][color=darkred]
> > > > > > ----------------------------------------
> > > > > > System.Xml
> > > > > > Assembly Version: 1.0.5000.0
> > > > > > Win32 Version: 1.1.4322.573
> > > > > > CodeBase:
> > > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll[color=blue][color=green][color=darkred]
> > > > > > ----------------------------------------
> > > > > > Microsoft.VisualBasic
> > > > > > Assembly Version: 7.0.5000.0
> > > > > > Win32 Version: 7.10.3052.4
> > > > > > CodeBase:
> > > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll[color=blue][color=green][color=darkred]
> > > > > > ----------------------------------------
> > > > > >
> > > > > > ************** JIT Debugging **************
> > > > > > To enable just in time (JIT) debugging, the config file for this
> > > > > > application or machine (machine.config) must have the
> > > > > > jitDebugging value set in the system.windows.forms section.
> > > > > > The application must also be compiled with debugging
> > > > > > enabled.
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>
>[/color]


Jody Gelowitz
Guest
 
Posts: n/a
#9: Nov 22 '05

re: Safe Printing


According to the documentation, the Internet Zone allows for Safe Printing.
Exactly what is "Safe Printing"? Is the documentation incorrect? Or am I
interpreting this incorrectly in assuming that I should be able to send
information to the printer with SafePrinting set?

With my sample application, I set the PrintingPermission to AllPrinting from
SafePrinting which worked if run locally, but still does not work when run
through the Internet Zone (launched from a web server). Adjusting the
permissions on the Internet Zone itself to allow for AllPrinting vs
SafePrinting is not an option for us.

Is printing even possible from a "No Touch Deployment" appliction run over
the web with the default settings for the Internet Zone (which has
SafePrinting and not AllPrinting)? If so, is there documentation or sample
code that I can run to see how this is done?

Thanks,
Jody


"Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
news:ek6SCLu1DHA.1736@TK2MSFTNGP09.phx.gbl...[color=blue]
> The only way I can get an Internet permission set equivalent to work is to
> up the printing permissions to all. Doesn't work with safe.
> --
> This posting is provided "AS IS" with no warranties, and confers no[/color]
rights.[color=blue]
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
>
> "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> news:%238UyrJt1DHA.4060@TK2MSFTNGP11.phx.gbl...[color=green]
> > I am still having difficulty in getting this to work. I have attached[/color][/color]
an[color=blue][color=green]
> > updated sample project with what I am trying to accomplish.
> >
> > The project will be run over the Internet Zone with the default security
> > settings which have limited UIPermissions and SafePrinting. The[/color]
> permissions[color=green]
> > that I have enforced on the project are listed below this message. One
> > change that I had to do was to move the UIPermission from Minimal to
> > Optional in order for the application to run over the Internet Zone.
> >
> > If somebody is able to get printing working with the permissions I have
> > described, could you please provide some sample code as to how it was[/color]
> done?[color=green]
> > I am not sure if I am just missing something small or if I am completely
> > off-base with this. Having the print dialog is not a requirement for[/color][/color]
this[color=blue][color=green]
> > if it violates the default security settings for the Internet Zone.
> >
> > Permissions on the Assembly:
> > ------------------------------
> > minimal permission set:
> > <PermissionSet class="System.Security.PermissionSet"
> > version="1">
> > <IPermission class="System.Security.Permissions.SecurityPermiss ion,
> > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > PublicKeyToken=b77a5c561934e089"
> > version="1"
> > Flags="Execution"/>
> > <IPermission class="System.Drawing.Printing.PrintingPermission,
> > System.Drawing, Version=1.0.5000.0, Culture=neutral,
> > PublicKeyToken=b03f5f7f11d50a3a"
> > version="1"
> > Level="SafePrinting"/>
> > </PermissionSet>
> >
> > optional permission set:
> > <PermissionSet class="System.Security.PermissionSet"
> > version="1">
> > <IPermission class="System.Security.Permissions.UIPermission,[/color][/color]
mscorlib,[color=blue][color=green]
> > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > version="1"
> > Unrestricted="true"/>
> > </PermissionSet>
> >
> > refused permission set:
> > Not specified
> >
> >
> >
> >
> >
> > "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
> > news:OBrh5tk1DHA.556@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > Let me admend this, you'll also need safe printing. Just to display[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > dialog box you're going to need unrestricted UIPermission, then to[/color][/color]
> perform[color=green][color=darkred]
> > > the printing you'll need the safe printing permission. Was able to[/color][/color][/color]
run[color=blue][color=green]
> > your[color=darkred]
> > > app to completion with safe printing permission. You may not need all[/color][/color]
> the[color=green][color=darkred]
> > > other permissions I came up with, you might try experimenting.
> > >
> > > Shel
> > >
> > > --
> > > This posting is provided "AS IS" with no warranties, and confers no[/color]
> > rights.[color=darkred]
> > > Use of included script samples are subject to the terms specified at
> > > http://www.microsoft.com/info/cpyright.htm
> > >
> > >
> > > "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
> > > news:e2A%23%23fk1DHA.1760@TK2MSFTNGP10.phx.gbl...
> > > > Here's the permission requirements I get when I check your[/color][/color]
> application:[color=green][color=darkred]
> > > >
> > > > <IPermission[/color][/color][/color]
class="System.Security.Permissions.EnvironmentPerm ission,[color=blue][color=green][color=darkred]
> > > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > > PublicKeyToken=b77a5c561934e089"
> > > > version="1"
> > > > Unrestricted="true"/>
> > > > <IPermission class="System.Security.Permissions.FileIOPermissio n,
> > > mscorlib,
> > > > Version=1.0.5000.0, Culture=neutral,[/color][/color][/color]
PublicKeyToken=b77a5c561934e089"[color=blue][color=green][color=darkred]
> > > > version="1"
> > > > Unrestricted="true"/>
> > > > <IPermission class="System.Security.Permissions.SecurityPermiss ion,
> > > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > > PublicKeyToken=b77a5c561934e089"
> > > > version="1"
> > > > Flags="UnmanagedCode, ControlEvidence"/>
> > > > <IPermission class="System.Security.Permissions.UIPermission,[/color][/color]
> mscorlib,[color=green][color=darkred]
> > > > Version=1.0.5000.0, Culture=neutral,[/color][/color][/color]
PublicKeyToken=b77a5c561934e089"[color=blue][color=green][color=darkred]
> > > > version="1"
> > > > Unrestricted="true"/>
> > > > <IPermission class="System.Net.WebPermission, System,[/color]
> > Version=1.0.5000.0,[color=darkred]
> > > > Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > > > version="1"
> > > > Unrestricted="true"/>
> > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
================================================== ==========================[color=blue][color=green][color=darkred]
> > > > ====
> > > > Shel
> > > > --
> > > > This posting is provided "AS IS" with no warranties, and confers no
> > > rights.
> > > > Use of included script samples are subject to the terms specified at
> > > > http://www.microsoft.com/info/cpyright.htm
> > > >
> > > >
> > > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > > > news:%23mFecRk1DHA.4032@tk2msftngp13.phx.gbl...
> > > > > The code in question is as follows:
> > > > >
> > > > > With dlgPrintSettings
> > > > >
> > > > > If Not (.ShowDialog() = DialogResult.Cancel) Then
> > > > >
> > > > > Try
> > > > >
> > > > > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> > > > >
> > > > > .Document.Print()
> > > > >
> > > > > TextBox1.AppendText("Print Successful")
> > > > >
> > > > > Catch ex As Exception
> > > > >
> > > > > Debug.WriteLine(ex.ToString)
> > > > >
> > > > > 'MsgBox(ex.ToString)
> > > > >
> > > > > End Try
> > > > >
> > > > > End If
> > > > >
> > > > > End With
> > > > >
> > > > >
> > > > >
> > > > > The security exception is thrown within the following line:
> > > > >
> > > > > If Not (.ShowDialog() = DialogResult.Cancel) Then
> > > > >
> > > > > after you click the PRINT button. The line below it never gets[/color][/color]
> called:[color=green][color=darkred]
> > > > >
> > > > > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> > > > >
> > > > >
> > > > >
> > > > > Thanks,
> > > > > Jody
> > > > >
> > > > > "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> > > > > news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...
> > > > > > Jody,
> > > > > >
> > > > > > I can not access your sample code. Could you please[/color][/color][/color]
post[color=blue]
> a[color=green][color=darkred]
> > > link
> > > > > to
> > > > > > or email me your code.
> > > > > >
> > > > > > Ken
> > > > > > ----------------
> > > > > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > > > > > news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...
> > > > > > >I am trying to find the definition of "Safe Printing" and[/color][/color][/color]
cannot[color=blue][color=green]
> > find[color=darkred]
> > > > out
> > > > > > > exactly what this entitles. The reason is that I am trying to[/color]
> > print[color=darkred]
> > > > > > > contents from a single textbox to no avail using the[/color][/color][/color]
PrintDialog[color=blue][color=green][color=darkred]
> > > > control
> > > > > > > under a security setting with only SafePrinting allowed.
> > > > > > >
> > > > > > > I have attached a sample project that I am using to try to
> > > accomplish
> > > > > > > this.
> > > > > > > The print dialog appears, but when I press the Print button, I[/color][/color]
> get[color=green][color=darkred]
> > > an
> > > > > > > exception (at the end of this message). Any ideas how I can[/color][/color]
> make[color=green][color=darkred]
> > > this
> > > > > > > work?
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Jody
> > > > > > >
> > > > > > >
> > > > > > > System.Security.SecurityException: Request for the permission[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > type
> > > > > > > System.Drawing.Printing.PrintingPermission, System.Drawing,
> > > > > > > Version=1.0.5000.0, Culture=neutral,[/color]
> > PublicKeyToken=b03f5f7f11d50a3a[color=darkred]
> > > > > > > failed.
> > > > > > > at
> > > > System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
> > > > > > > grantedSet, PermissionSet deniedSet, CodeAccessPermission[/color][/color]
> demand,[color=green][color=darkred]
> > > > > > > PermissionToken permToken)
> > > > > > > at[/color]
> > System.Security.CodeAccessSecurityEngine.Check(Per missionToken[color=darkred]
> > > > > > > permToken, CodeAccessPermission demand, StackCrawlMark&[/color][/color]
> stackMark,[color=green][color=darkred]
> > > > Int32
> > > > > > > checkFrames, Int32 unrestrictedOverride)
> > > > > > > at
> > > > System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
> > > > > > > cap, StackCrawlMark& stackMark)
> > > > > > > at System.Security.CodeAccessPermission.Demand()
> > > > > > > at[/color][/color][/color]
System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr[color=blue][color=green][color=darkred]
> > > > > hdevmode)
> > > > > > > at[/color]
> > System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG[color=darkred]
> > > > > data,
> > > > > > > PrinterSettings settings, PageSettings pageSettings)
> > > > > > > at System.Windows.Forms.PrintDialog.RunDialog(IntPtr[/color][/color]
> hwndOwner)[color=green][color=darkred]
> > > > > > > at System.Windows.Forms.CommonDialog.ShowDialog()
> > > > > > > at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
> > > > > > > at System.Windows.Forms.Control.OnClick(EventArgs e)
> > > > > > > at System.Windows.Forms.Button.OnClick(EventArgs e)
> > > > > > > at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs[/color][/color]
> mevent)[color=green][color=darkred]
> > > > > > > at System.Windows.Forms.Control.WmMouseUp(Message& m,[/color]
> > MouseButtons[color=darkred]
> > > > > > > button, Int32 clicks)
> > > > > > > at System.Windows.Forms.Control.WndProc(Message& m)
> > > > > > > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> > > > > > > at System.Windows.Forms.Button.WndProc(Message& m)
> > > > > > > at[/color][/color][/color]
System.Windows.Forms.ControlNativeWindow.OnMessage (Message&[color=blue][color=green]
> > m)[color=darkred]
> > > > > > > at System.Windows.Forms.ControlNativeWindow.WndProc(M essage&[/color][/color]
> m)[color=green][color=darkred]
> > > > > > > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,[/color][/color]
> Int32[color=green][color=darkred]
> > > > msg,
> > > > > > > IntPtr wparam, IntPtr lparam)
> > > > > > >
> > > > > > >
> > > > > > > ************** Loaded Assemblies **************
> > > > > > > mscorlib
> > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > CodeBase:
> > > > > > >[/color][/color]
> file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll[color=green][color=darkred]
> > > > > > > ----------------------------------------
> > > > > > > System.Drawing
> > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > CodeBase:
> > > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[color=blue][color=green][color=darkred]
> > > > > > > ----------------------------------------
> > > > > > > System
> > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > CodeBase:
> > > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[color=blue][color=green][color=darkred]
> > > > > > > ----------------------------------------
> > > > > > > RegexAssembly4_0
> > > > > > > Assembly Version: 0.0.0.0
> > > > > > > Win32 Version: n/a
> > > > > > > CodeBase:
> > > > > > > ----------------------------------------
> > > > > > > IEExecRemote
> > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > CodeBase:
> > > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll[color=blue][color=green][color=darkred]
> > > > > > > ----------------------------------------
> > > > > > > PrintTest
> > > > > > > Assembly Version: 1.0.1468.23656
> > > > > > > Win32 Version: n/a
> > > > > > > CodeBase:[/color]
> > http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE[color=darkred]
> > > > > > > ----------------------------------------
> > > > > > > System.Windows.Forms
> > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > CodeBase:
> > > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[color=blue][color=green][color=darkred]
> > > > > > > ----------------------------------------
> > > > > > > System.Xml
> > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > CodeBase:
> > > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll[color=blue][color=green][color=darkred]
> > > > > > > ----------------------------------------
> > > > > > > Microsoft.VisualBasic
> > > > > > > Assembly Version: 7.0.5000.0
> > > > > > > Win32 Version: 7.10.3052.4
> > > > > > > CodeBase:
> > > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll[color=blue][color=green][color=darkred]
> > > > > > > ----------------------------------------
> > > > > > >
> > > > > > > ************** JIT Debugging **************
> > > > > > > To enable just in time (JIT) debugging, the config file for[/color][/color][/color]
this[color=blue][color=green][color=darkred]
> > > > > > > application or machine (machine.config) must have the
> > > > > > > jitDebugging value set in the system.windows.forms section.
> > > > > > > The application must also be compiled with debugging
> > > > > > > enabled.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >
> >[/color]
>
>[/color]


Shel Blauman [MSFT]
Guest
 
Posts: n/a
#10: Nov 22 '05

re: Safe Printing


You'll notice a "send comments on this topic" at the bottom of the page for
PrintDocument.Print (the one that states safe printing is the required
permission). I clicked on that and sent in a comment about safe printing
not working. Should get to the writer and should result in a bug being
filed unless you and I are missing something. You could do the same if you
would like to hear back directly. I've checked for bugs and don't see any
filed for this.

Shel

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
news:eVupWfu1DHA.3216@TK2MSFTNGP11.phx.gbl...[color=blue]
> According to the documentation, the Internet Zone allows for Safe[/color]
Printing.[color=blue]
> Exactly what is "Safe Printing"? Is the documentation incorrect? Or am I
> interpreting this incorrectly in assuming that I should be able to send
> information to the printer with SafePrinting set?
>
> With my sample application, I set the PrintingPermission to AllPrinting[/color]
from[color=blue]
> SafePrinting which worked if run locally, but still does not work when run
> through the Internet Zone (launched from a web server). Adjusting the
> permissions on the Internet Zone itself to allow for AllPrinting vs
> SafePrinting is not an option for us.
>
> Is printing even possible from a "No Touch Deployment" appliction run over
> the web with the default settings for the Internet Zone (which has
> SafePrinting and not AllPrinting)? If so, is there documentation or[/color]
sample[color=blue]
> code that I can run to see how this is done?
>
> Thanks,
> Jody
>
>
> "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
> news:ek6SCLu1DHA.1736@TK2MSFTNGP09.phx.gbl...[color=green]
> > The only way I can get an Internet permission set equivalent to work is[/color][/color]
to[color=blue][color=green]
> > up the printing permissions to all. Doesn't work with safe.
> > --
> > This posting is provided "AS IS" with no warranties, and confers no[/color]
> rights.[color=green]
> > Use of included script samples are subject to the terms specified at
> > http://www.microsoft.com/info/cpyright.htm
> >
> >
> > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > news:%238UyrJt1DHA.4060@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > I am still having difficulty in getting this to work. I have attached[/color][/color]
> an[color=green][color=darkred]
> > > updated sample project with what I am trying to accomplish.
> > >
> > > The project will be run over the Internet Zone with the default[/color][/color][/color]
security[color=blue][color=green][color=darkred]
> > > settings which have limited UIPermissions and SafePrinting. The[/color]
> > permissions[color=darkred]
> > > that I have enforced on the project are listed below this message.[/color][/color][/color]
One[color=blue][color=green][color=darkred]
> > > change that I had to do was to move the UIPermission from Minimal to
> > > Optional in order for the application to run over the Internet Zone.
> > >
> > > If somebody is able to get printing working with the permissions I[/color][/color][/color]
have[color=blue][color=green][color=darkred]
> > > described, could you please provide some sample code as to how it was[/color]
> > done?[color=darkred]
> > > I am not sure if I am just missing something small or if I am[/color][/color][/color]
completely[color=blue][color=green][color=darkred]
> > > off-base with this. Having the print dialog is not a requirement for[/color][/color]
> this[color=green][color=darkred]
> > > if it violates the default security settings for the Internet Zone.
> > >
> > > Permissions on the Assembly:
> > > ------------------------------
> > > minimal permission set:
> > > <PermissionSet class="System.Security.PermissionSet"
> > > version="1">
> > > <IPermission class="System.Security.Permissions.SecurityPermiss ion,
> > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > PublicKeyToken=b77a5c561934e089"
> > > version="1"
> > > Flags="Execution"/>
> > > <IPermission class="System.Drawing.Printing.PrintingPermission,
> > > System.Drawing, Version=1.0.5000.0, Culture=neutral,
> > > PublicKeyToken=b03f5f7f11d50a3a"
> > > version="1"
> > > Level="SafePrinting"/>
> > > </PermissionSet>
> > >
> > > optional permission set:
> > > <PermissionSet class="System.Security.PermissionSet"
> > > version="1">
> > > <IPermission class="System.Security.Permissions.UIPermission,[/color][/color]
> mscorlib,[color=green][color=darkred]
> > > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > > version="1"
> > > Unrestricted="true"/>
> > > </PermissionSet>
> > >
> > > refused permission set:
> > > Not specified
> > >
> > >
> > >
> > >
> > >
> > > "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
> > > news:OBrh5tk1DHA.556@TK2MSFTNGP11.phx.gbl...
> > > > Let me admend this, you'll also need safe printing. Just to display[/color][/color]
> the[color=green][color=darkred]
> > > > dialog box you're going to need unrestricted UIPermission, then to[/color]
> > perform[color=darkred]
> > > > the printing you'll need the safe printing permission. Was able to[/color][/color]
> run[color=green][color=darkred]
> > > your
> > > > app to completion with safe printing permission. You may not need[/color][/color][/color]
all[color=blue][color=green]
> > the[color=darkred]
> > > > other permissions I came up with, you might try experimenting.
> > > >
> > > > Shel
> > > >
> > > > --
> > > > This posting is provided "AS IS" with no warranties, and confers no
> > > rights.
> > > > Use of included script samples are subject to the terms specified at
> > > > http://www.microsoft.com/info/cpyright.htm
> > > >
> > > >
> > > > "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in[/color][/color][/color]
message[color=blue][color=green][color=darkred]
> > > > news:e2A%23%23fk1DHA.1760@TK2MSFTNGP10.phx.gbl...
> > > > > Here's the permission requirements I get when I check your[/color]
> > application:[color=darkred]
> > > > >
> > > > > <IPermission[/color][/color]
> class="System.Security.Permissions.EnvironmentPerm ission,[color=green][color=darkred]
> > > > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > > > PublicKeyToken=b77a5c561934e089"
> > > > > version="1"
> > > > > Unrestricted="true"/>
> > > > > <IPermission class="System.Security.Permissions.FileIOPermissio n,
> > > > mscorlib,
> > > > > Version=1.0.5000.0, Culture=neutral,[/color][/color]
> PublicKeyToken=b77a5c561934e089"[color=green][color=darkred]
> > > > > version="1"
> > > > > Unrestricted="true"/>
> > > > > <IPermission[/color][/color][/color]
class="System.Security.Permissions.SecurityPermiss ion,[color=blue][color=green][color=darkred]
> > > > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > > > PublicKeyToken=b77a5c561934e089"
> > > > > version="1"
> > > > > Flags="UnmanagedCode, ControlEvidence"/>
> > > > > <IPermission class="System.Security.Permissions.UIPermission,[/color]
> > mscorlib,[color=darkred]
> > > > > Version=1.0.5000.0, Culture=neutral,[/color][/color]
> PublicKeyToken=b77a5c561934e089"[color=green][color=darkred]
> > > > > version="1"
> > > > > Unrestricted="true"/>
> > > > > <IPermission class="System.Net.WebPermission, System,
> > > Version=1.0.5000.0,
> > > > > Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > > > > version="1"
> > > > > Unrestricted="true"/>
> > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
================================================== ==========================[color=blue][color=green][color=darkred]
> > > > > ====
> > > > > Shel
> > > > > --
> > > > > This posting is provided "AS IS" with no warranties, and confers[/color][/color][/color]
no[color=blue][color=green][color=darkred]
> > > > rights.
> > > > > Use of included script samples are subject to the terms specified[/color][/color][/color]
at[color=blue][color=green][color=darkred]
> > > > > http://www.microsoft.com/info/cpyright.htm
> > > > >
> > > > >
> > > > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > > > > news:%23mFecRk1DHA.4032@tk2msftngp13.phx.gbl...
> > > > > > The code in question is as follows:
> > > > > >
> > > > > > With dlgPrintSettings
> > > > > >
> > > > > > If Not (.ShowDialog() = DialogResult.Cancel) Then
> > > > > >
> > > > > > Try
> > > > > >
> > > > > > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> > > > > >
> > > > > > .Document.Print()
> > > > > >
> > > > > > TextBox1.AppendText("Print Successful")
> > > > > >
> > > > > > Catch ex As Exception
> > > > > >
> > > > > > Debug.WriteLine(ex.ToString)
> > > > > >
> > > > > > 'MsgBox(ex.ToString)
> > > > > >
> > > > > > End Try
> > > > > >
> > > > > > End If
> > > > > >
> > > > > > End With
> > > > > >
> > > > > >
> > > > > >
> > > > > > The security exception is thrown within the following line:
> > > > > >
> > > > > > If Not (.ShowDialog() = DialogResult.Cancel) Then
> > > > > >
> > > > > > after you click the PRINT button. The line below it never gets[/color]
> > called:[color=darkred]
> > > > > >
> > > > > > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> > > > > >
> > > > > >
> > > > > >
> > > > > > Thanks,
> > > > > > Jody
> > > > > >
> > > > > > "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> > > > > > news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...
> > > > > > > Jody,
> > > > > > >
> > > > > > > I can not access your sample code. Could you please[/color][/color]
> post[color=green]
> > a[color=darkred]
> > > > link
> > > > > > to
> > > > > > > or email me your code.
> > > > > > >
> > > > > > > Ken
> > > > > > > ----------------
> > > > > > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in[/color][/color][/color]
message[color=blue][color=green][color=darkred]
> > > > > > > news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...
> > > > > > > >I am trying to find the definition of "Safe Printing" and[/color][/color]
> cannot[color=green][color=darkred]
> > > find
> > > > > out
> > > > > > > > exactly what this entitles. The reason is that I am trying[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > print
> > > > > > > > contents from a single textbox to no avail using the[/color][/color]
> PrintDialog[color=green][color=darkred]
> > > > > control
> > > > > > > > under a security setting with only SafePrinting allowed.
> > > > > > > >
> > > > > > > > I have attached a sample project that I am using to try to
> > > > accomplish
> > > > > > > > this.
> > > > > > > > The print dialog appears, but when I press the Print button,[/color][/color][/color]
I[color=blue][color=green]
> > get[color=darkred]
> > > > an
> > > > > > > > exception (at the end of this message). Any ideas how I can[/color]
> > make[color=darkred]
> > > > this
> > > > > > > > work?
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > > Jody
> > > > > > > >
> > > > > > > >
> > > > > > > > System.Security.SecurityException: Request for the[/color][/color][/color]
permission[color=blue]
> of[color=green][color=darkred]
> > > > type
> > > > > > > > System.Drawing.Printing.PrintingPermission, System.Drawing,
> > > > > > > > Version=1.0.5000.0, Culture=neutral,
> > > PublicKeyToken=b03f5f7f11d50a3a
> > > > > > > > failed.
> > > > > > > > at
> > > > > System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
> > > > > > > > grantedSet, PermissionSet deniedSet, CodeAccessPermission[/color]
> > demand,[color=darkred]
> > > > > > > > PermissionToken permToken)
> > > > > > > > at
> > > System.Security.CodeAccessSecurityEngine.Check(Per missionToken
> > > > > > > > permToken, CodeAccessPermission demand, StackCrawlMark&[/color]
> > stackMark,[color=darkred]
> > > > > Int32
> > > > > > > > checkFrames, Int32 unrestrictedOverride)
> > > > > > > > at
> > > > >[/color][/color][/color]
System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission[color=blue][color=green][color=darkred]
> > > > > > > > cap, StackCrawlMark& stackMark)
> > > > > > > > at System.Security.CodeAccessPermission.Demand()
> > > > > > > > at[/color][/color]
> System.Drawing.Printing.PrinterSettings.SetHdevmod e(IntPtr[color=green][color=darkred]
> > > > > > hdevmode)
> > > > > > > > at
> > > System.Windows.Forms.PrintDialog.UpdatePrinterSett ings(PRINTDLG
> > > > > > data,
> > > > > > > > PrinterSettings settings, PageSettings pageSettings)
> > > > > > > > at System.Windows.Forms.PrintDialog.RunDialog(IntPtr[/color]
> > hwndOwner)[color=darkred]
> > > > > > > > at System.Windows.Forms.CommonDialog.ShowDialog()
> > > > > > > > at PrintTest.Form1.Button1_Click(Object sender, EventArgs[/color][/color][/color]
e)[color=blue][color=green][color=darkred]
> > > > > > > > at System.Windows.Forms.Control.OnClick(EventArgs e)
> > > > > > > > at System.Windows.Forms.Button.OnClick(EventArgs e)
> > > > > > > > at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs[/color]
> > mevent)[color=darkred]
> > > > > > > > at System.Windows.Forms.Control.WmMouseUp(Message& m,
> > > MouseButtons
> > > > > > > > button, Int32 clicks)
> > > > > > > > at System.Windows.Forms.Control.WndProc(Message& m)
> > > > > > > > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> > > > > > > > at System.Windows.Forms.Button.WndProc(Message& m)
> > > > > > > > at[/color][/color]
> System.Windows.Forms.ControlNativeWindow.OnMessage (Message&[color=green][color=darkred]
> > > m)
> > > > > > > > at[/color][/color][/color]
System.Windows.Forms.ControlNativeWindow.WndProc(M essage&[color=blue][color=green]
> > m)[color=darkred]
> > > > > > > > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,[/color]
> > Int32[color=darkred]
> > > > > msg,
> > > > > > > > IntPtr wparam, IntPtr lparam)
> > > > > > > >
> > > > > > > >
> > > > > > > > ************** Loaded Assemblies **************
> > > > > > > > mscorlib
> > > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > > CodeBase:
> > > > > > > >[/color]
> > file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll[color=darkred]
> > > > > > > > ----------------------------------------
> > > > > > > > System.Drawing
> > > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > > CodeBase:
> > > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll[color=blue][color=green][color=darkred]
> > > > > > > > ----------------------------------------
> > > > > > > > System
> > > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > > CodeBase:
> > > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll[color=blue][color=green][color=darkred]
> > > > > > > > ----------------------------------------
> > > > > > > > RegexAssembly4_0
> > > > > > > > Assembly Version: 0.0.0.0
> > > > > > > > Win32 Version: n/a
> > > > > > > > CodeBase:
> > > > > > > > ----------------------------------------
> > > > > > > > IEExecRemote
> > > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > > CodeBase:
> > > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll[color=blue][color=green][color=darkred]
> > > > > > > > ----------------------------------------
> > > > > > > > PrintTest
> > > > > > > > Assembly Version: 1.0.1468.23656
> > > > > > > > Win32 Version: n/a
> > > > > > > > CodeBase:
> > > http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
> > > > > > > > ----------------------------------------
> > > > > > > > System.Windows.Forms
> > > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > > CodeBase:
> > > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll[color=blue][color=green][color=darkred]
> > > > > > > > ----------------------------------------
> > > > > > > > System.Xml
> > > > > > > > Assembly Version: 1.0.5000.0
> > > > > > > > Win32 Version: 1.1.4322.573
> > > > > > > > CodeBase:
> > > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll[color=blue][color=green][color=darkred]
> > > > > > > > ----------------------------------------
> > > > > > > > Microsoft.VisualBasic
> > > > > > > > Assembly Version: 7.0.5000.0
> > > > > > > > Win32 Version: 7.10.3052.4
> > > > > > > > CodeBase:
> > > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll[color=blue][color=green][color=darkred]
> > > > > > > > ----------------------------------------
> > > > > > > >
> > > > > > > > ************** JIT Debugging **************
> > > > > > > > To enable just in time (JIT) debugging, the config file for[/color][/color]
> this[color=green][color=darkred]
> > > > > > > > application or machine (machine.config) must have the
> > > > > > > > jitDebugging value set in the system.windows.forms section.
> > > > > > > > The application must also be compiled with debugging
> > > > > > > > enabled.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread


Similar .NET Framework bytes