Home All Groups Group Topic Archive Search About

Re: Printing in Win98 problem

Author
30 Mar 2005 2:17 PM
Senthil Kumar S
Just use caspol.exe which is present in .NET Framework. Provide 'Full Trust'
to run your code.


Show quoteHide quote
"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.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
>

Author
30 Mar 2005 5:18 PM
Crouchie1998
Author
31 Mar 2005 9:10 AM
C-Services Holland b.v.
Crouchie1998 wrote:
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.
Author
31 Mar 2005 9:11 AM
C-Services Holland b.v.
Thanks I will look into that. I thought something like Full Trust was
only nescesarry for network drives.

Senthil Kumar S wrote:

Show quoteHide quote
> 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.