473,832 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 printpreviewdia log1 and the following code:

Private Sub PrintDocument1_ PrintPage(ByVal sender as System.Object,
ByVal e As System.Drawing. Printing.Printp ageEventArgs) handles
PrintDocument1. PrintPage
'print Testpage to the printer
e.Graphics.Draw String("Testpag e", printFont, New
SolidBrush(Colo r.Black), 100, 100)
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
PrintDialog1.Pr interSettings = PrintDocument1. PrinterSettings
PrintDialog1.Sh owDialog()
printFont = New Font("Arial", 10)
PrintPreviewDia log1.Document = PrintDocument1
PrintPreviewDia log1.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 SecurityExcepti on. 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.Printi ngPermission, System.Drawing,
Version=1.0.330 0.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.NullRefe renceException: Object reference not set to an instance
of an object.
at System.Windows. Forms.PrintPrev ieuwControls.Ca lculatePageInfo ()
at System.Windows. Forms.Control.I nvokeMarshaledC allbacks()

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

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 1977
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 printpreviewdia log1 and the following code:

Private Sub PrintDocument1_ PrintPage(ByVal sender as System.Object,
ByVal e As System.Drawing. Printing.Printp ageEventArgs) handles
PrintDocument1. PrintPage
'print Testpage to the printer
e.Graphics.Draw String("Testpag e", printFont, New
SolidBrush(Colo r.Black), 100, 100)
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
PrintDialog1.Pr interSettings = PrintDocument1. PrinterSettings
PrintDialog1.Sh owDialog()
printFont = New Font("Arial", 10)
PrintPreviewDia log1.Document = PrintDocument1
PrintPreviewDia log1.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 SecurityExcepti on. 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.Printi ngPermission, System.Drawing,
Version=1.0.330 0.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.NullRefe renceException: Object reference not set to an instance
of an object.
at System.Windows. Forms.PrintPrev ieuwControls.Ca lculatePageInfo ()
at System.Windows. Forms.Control.I nvokeMarshaledC allbacks()

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

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 printpreviewdia log1 and the following code:

Private Sub PrintDocument1_ PrintPage(ByVal sender as System.Object,
ByVal e As System.Drawing. Printing.Printp ageEventArgs) handles
PrintDocument1. PrintPage
'print Testpage to the printer
e.Graphics.Draw String("Testpag e", printFont, New
SolidBrush(Colo r.Black), 100, 100)
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
PrintDialog1.Pr interSettings = PrintDocument1. PrinterSettings
PrintDialog1.Sh owDialog()
printFont = New Font("Arial", 10)
PrintPreviewDia log1.Document = PrintDocument1
PrintPreviewDia log1.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 SecurityExcepti on. 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.Printi ngPermission, System.Drawing,
Version=1.0.330 0.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.NullRefe renceException: Object reference not set to an instance
of an object.
at System.Windows. Forms.PrintPrev ieuwControls.Ca lculatePageInfo ()
at System.Windows. Forms.Control.I nvokeMarshaledC allbacks()

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

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
3027
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 of the printing, I arranged the graphic elements on the page the way it should be. When I got to printing text, it went across the page, not down as I need it to go. I tried to use the hDC.SetWorldTransform(0, -1, 1, 0, 0, 0) command to rotate...
19
3218
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 still don't know if it supports printing, so I'm looking for a Python module that could do it. I want to print a PDF file just like if I were doing it from Acrobat. Daniel.
5
9439
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 without a fieldset to almost 50 Megs. This seems to only be noticeable in IE, but I can replicate every time. Example: (70 megs sent to printer) <form>
0
1201
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 data to receipt printer '************************************************************************ Private Sub cmdPrintReceipt_Click() Printer.CurrentX = 0: Printer.CurrentY = 0 Printer.FontName = "Arial"
2
1832
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 XPSP2 system over a peer to peer network ? Although both machines can see each other fine, DCOM seems to jump in when I try to connect to the Win98 machine in Debug>Processes>Name and tells me the
6
2300
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 to a web service on the other (not relevant I guess). Some stored procedures consume xml produced by DataSet objects (values as elements) using OPENXML statements. The application should be distributed among users having also Win98. Established...
1
2935
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 an HP 170 JetDirect on an internal network. The PC has McAfee anti-virus (v7, fully up to date) and all Windows 98 critical and non-critical updates loaded. Recently, certain reports are printing with either the occasional incorrect character...
3
3328
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 printer. I know the printer is communicating with the OS because I can print text with notepad. Does this application need to be compiled under the win98 evironment? Or is there a fix for this type of problem? Any suggestions would be appreciated.
7
2180
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", None, ".", 0) but it raises an exception with the message: error: (31, 'ShellExecute', 'A device attached to the system is not
0
10497
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9319
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7753
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5623
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4420
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.