By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

Printing in Win98 problem

P: n/a
Hi all,

I've run into a problem trying to print from vb.net (2002) in Windows
98. To test it I've setup a single form with a button and the following
code:

'the form has a button called Button1, a printdocument1, a printdialog1,
a printpreviewdialog1 and the following code:

Private Sub PrintDocument1_PrintPage(ByVal sender as System.Object,
ByVal e As System.Drawing.Printing.PrintpageEventArgs) handles
PrintDocument1.PrintPage
'print Testpage to the printer
e.Graphics.DrawString("Testpage", printFont, New
SolidBrush(Color.Black), 100, 100)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
PrintDialog1.ShowDialog()
printFont = New Font("Arial", 10)
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.Show()
End Sub

This works just fine on Win2000 or XP, but on the Windows98 station it
throws an exception when I click the button:

"The application attempted to perform an operation not allowed by the
security policy. The operation required the SecurityException. To grant
this application the required permission please contact your system
administrator, or use the Microsoft .NET security policy administration
tool.

< if you click...snip>

Request for the permission of type
System.Drawing.Printing.PrintingPermission, System.Drawing,
Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b-3f5f7f11d50a3a failed."

Why is it complaining about security stuff. It's Win98. It doesn't have
policies AFAIK. Besides it's a computer of the sysop, he wouldn't
confine himself. The error occured printing to a real printer and to a
PDF printing driver.

I made this test because my application threw an error when printing but
that one was different:

***** Exception Text ******
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Windows.Forms.PrintPrevieuwControls.Calcula tePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallba cks()

***************************

My application runs like it should on all other platforms we have except
Windows 98 (we tried different machines). Now the docs stated for all
components used that the platforms supported was Win98 and up, so that
shouldn't be the problem. All machines have the .NET framework
installed. Any idea's what I've messed up here?

Rinze van Huizen
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hmm nobody knows anything about this?

Rinze van Huizen

C-Services Holland b.v. wrote:
Hi all,

I've run into a problem trying to print from vb.net (2002) in Windows
98. To test it I've setup a single form with a button and the following
code:

'the form has a button called Button1, a printdocument1, a printdialog1,
a printpreviewdialog1 and the following code:

Private Sub PrintDocument1_PrintPage(ByVal sender as System.Object,
ByVal e As System.Drawing.Printing.PrintpageEventArgs) handles
PrintDocument1.PrintPage
'print Testpage to the printer
e.Graphics.DrawString("Testpage", printFont, New
SolidBrush(Color.Black), 100, 100)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
PrintDialog1.ShowDialog()
printFont = New Font("Arial", 10)
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.Show()
End Sub

This works just fine on Win2000 or XP, but on the Windows98 station it
throws an exception when I click the button:

"The application attempted to perform an operation not allowed by the
security policy. The operation required the SecurityException. To grant
this application the required permission please contact your system
administrator, or use the Microsoft .NET security policy administration
tool.

< if you click...snip>

Request for the permission of type
System.Drawing.Printing.PrintingPermission, System.Drawing,
Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b-3f5f7f11d50a3a failed."

Why is it complaining about security stuff. It's Win98. It doesn't have
policies AFAIK. Besides it's a computer of the sysop, he wouldn't
confine himself. The error occured printing to a real printer and to a
PDF printing driver.

I made this test because my application threw an error when printing but
that one was different:

***** Exception Text ******
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Windows.Forms.PrintPrevieuwControls.Calcula tePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallba cks()

***************************

My application runs like it should on all other platforms we have except
Windows 98 (we tried different machines). Now the docs stated for all
components used that the platforms supported was Win98 and up, so that
shouldn't be the problem. All machines have the .NET framework
installed. Any idea's what I've messed up here?

Rinze van Huizen

Nov 21 '05 #2

P: n/a
Just use caspol.exe which is present in .NET Framework. Provide 'Full Trust'
to run your code.
"C-Services Holland b.v." wrote:
Hmm nobody knows anything about this?

Rinze van Huizen

C-Services Holland b.v. wrote:
Hi all,

I've run into a problem trying to print from vb.net (2002) in Windows
98. To test it I've setup a single form with a button and the following
code:

'the form has a button called Button1, a printdocument1, a printdialog1,
a printpreviewdialog1 and the following code:

Private Sub PrintDocument1_PrintPage(ByVal sender as System.Object,
ByVal e As System.Drawing.Printing.PrintpageEventArgs) handles
PrintDocument1.PrintPage
'print Testpage to the printer
e.Graphics.DrawString("Testpage", printFont, New
SolidBrush(Color.Black), 100, 100)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
PrintDialog1.ShowDialog()
printFont = New Font("Arial", 10)
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.Show()
End Sub

This works just fine on Win2000 or XP, but on the Windows98 station it
throws an exception when I click the button:

"The application attempted to perform an operation not allowed by the
security policy. The operation required the SecurityException. To grant
this application the required permission please contact your system
administrator, or use the Microsoft .NET security policy administration
tool.

< if you click...snip>

Request for the permission of type
System.Drawing.Printing.PrintingPermission, System.Drawing,
Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b-3f5f7f11d50a3a failed."

Why is it complaining about security stuff. It's Win98. It doesn't have
policies AFAIK. Besides it's a computer of the sysop, he wouldn't
confine himself. The error occured printing to a real printer and to a
PDF printing driver.

I made this test because my application threw an error when printing but
that one was different:

***** Exception Text ******
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Windows.Forms.PrintPrevieuwControls.Calcula tePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallba cks()

***************************

My application runs like it should on all other platforms we have except
Windows 98 (we tried different machines). Now the docs stated for all
components used that the platforms supported was Win98 and up, so that
shouldn't be the problem. All machines have the .NET framework
installed. Any idea's what I've messed up here?

Rinze van Huizen

Nov 21 '05 #3

P: n/a
Crouchie1998 wrote:
This may help:

http://support.microsoft.com/default...b;en-us;322090


I don't want to send raw data to the printer. I've tried the Scribble
example program that comes with VB.NET to exclude any mistakes on my end
and that fails too on the Win98 box.

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #5

P: n/a
Thanks I will look into that. I thought something like Full Trust was
only nescesarry for network drives.

Senthil Kumar S wrote:
Just use caspol.exe which is present in .NET Framework. Provide 'Full Trust'
to run your code.


--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.