Printing in Win98 problem

  • Thread starter C-Services Holland b.v.
  • Start date
C

C-Services Holland b.v.

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.CalculatePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

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

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
 
G

Guest

Just use caspol.exe which is present in .NET Framework. Provide 'Full Trust'
to run your code.
 
C

C-Services Holland b.v.

Thanks I will look into that. I thought something like Full Trust was
only nescesarry for network drives.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top