473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Printing in Win98 problem

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
5 1928
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Darcy Kahle | last post by:
I am trying to do some advanced printing in python using the win32ui module, and have run into an issue. I need to print a page landscape. As I could not determine how to specify the orientation...
19
by: dcrespo | last post by:
Hi all... Is there a way to print a PDF file directly from Python without having Acrobat installed? I know about ReportLab. It's a python module that lets you create almost any PDF document, but I...
5
by: rd | last post by:
Has anyone else noticed a problem when printing html with fieldsets in them? Whenever I print even the simplest document with a fieldset, the amount of data sent to the printer jumps from a few K...
0
by: Samuel Lee | last post by:
Could anyone convert the following vb 6.0 codes into vb.net version? '************************************************************************ '** Button to print a sales receipt - spool print...
2
by: jon morgan | last post by:
Hi, I need to debug my app. under Windows 98. Although VS.net can't be installed it I have been able to install both Framework 1.1 and the SDK. Can I debug the app. in VS.net remotely from an...
6
by: Andrzej | last post by:
Used to read newsgroup for answers, now have to ask for them as well. I have an application (C#, .NET 1.1) that connects to local db on MSDE 2000 SP3a (using ADO from MDAC 2.71) on one side and...
1
by: AAVF | last post by:
We have a problem that has only started in the last few weeks. We have an Access 2000 database running on a P300 Win98 PC. The PC outputs Access reports to an HP LaserJet 5L printer, connected to...
3
by: Les | last post by:
I have made an app with vb.net 2002 and compiled it in the XP environment. It works great in this environment but when I install it to a computer running win98, I cannot communicate with the...
7
by: Maravilloso | last post by:
Hi I'm trying to automatically send a postscript file to be printed to the default printer in a Win98 PC, by means of using the instrucction: win32api.ShellExecute (0, "print", "file.ps",...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.