Very strange printing Problem in VB.NET 
Author Message
 Very strange printing Problem in VB.NET

Hi Guys,
my problem is as follows. I've written an application in VB.NET 2003.
Now as I'm nearly finished with that I've tested it. I ran it on my
own XP machine where it worked fine, but then I went over to test it
on three Win98SE machines and it didn't work on each of them. I've
already found out where my mistake is, but I can't handle it. And here
it goes: My App prints pages with a barcode on it. I use Code39 as a
Font (You can download for free at
http://www.*-*-*.com/ )
and this Font makes all the trouble, as soon as I change it with e.g.
Arial it all works fine (except that it doesn't print a barcode on my
page). But this Font works in other Applications on those Win98SE
machines, e.g. I can use them in Word, Excel and stuff. And in the
end, I got on two of the three machines for 1 time the correct output
with thee fonts, but that worked only like one time on two of them.
After trying again it stucked again.
All of those machines have the .NET Framework 1.1 installed (I
compiled also for that) and maybe interesting, too, although I don't
think so, all of those machines have mdac 2.7.
Now,, the exact error messages I get differ. One machine even can't
handle my try-catch and gives me a blue screen saying "Schwerer
Ausnahmefehler 0E" (maybe "dangerous exception error 0E") at address
0028:C0059C8D.
Sometimes this machine can handle my try-catch and gives me this
error: "System.ArithmeticException: Overflow or Underflow in the
arithmetic operation"

I really don't know how to handle this mistake, i've also tried a font
for code128 from another producer (Lexware) which gave me the same
Error. But however, when using "normal" fonts I don't get this error.
Is it possible, that Win98 can't measure the width of a string written
in BarccodeFont? Because I'm using the
Graphics.MeasureString()-Function .

OK, finally I give you here my declaration of the Font and some
printing code, maybe I just declared something wrong (I'm quite new to
.NET), so thanks for reading, your help is very much appreciated.

| Dim BarFont As Font = New Font("Code39 Text", 28, FontStyle.Regular, GraphicsUnit.Point)
| Dim x as Integer
| e.Graphics.DrawString("Test",MyFont,Brushes.Black,0,0)
| x=e.Graphics.MeasureString("bla",MyFont)
| 'x might be used later to position text later...

This all is in the PrintPage Event-Handler of My PrintDocument Prog.
And I can't figure out whats wrong exactly. Thanks again for your
help,

David.

Gru?,
David.



Mon, 28 Nov 2005 00:10:50 GMT  
 Very strange printing Problem in VB.NET

Quote:
> a very long problem description...

OK, I've finally solved my problem myself. The problem really was the
declaration of my Barcode-Font. Remember, I declared it in my
PrintpageEvent-Handler like that:

| Dim MyFont As Font = New Font("Code39 Text", 28, FontStyle.Regular, GraphicsUnit.Point)

I put that between to MsgBoxes and found out that this is my Problem
as the first one popped up and the second one didn't. I also found
out, that this error seems to occur randomly, as I ran this program
(without changing the code or something else!) several times on a
machine. On this machine I got most of the times the catched
ArithmeticException, but a (very very) few times it printed my sheet
with the correct Barcode!

Anyways, I tried a little and found out that this error doesn't occur
when I do the following: I changed my declaration to

| Public BarFont As Font = New Font("Code39 Text", 28, FontStyle.Regular, GraphicsUnit.Point)

and put it in the global part of my form-class, so that it would be
declared only one time, when I would call a new instance of my form
class and not everytime when the PrintPageEvent happens. I've tested
this on two of my machines and by now I didn't get any error, and so
far I can tell that this seems to solve my problem.

But what I still don't know is why I have to declare this font
globally (and by the way, all my other fonts, like "Arial" and stuff
still are declared inside the PrintPageEvent-Handler)? Is there any
cause why my first try wouldn't work? Or is this maybe a VB.Net bug?
Anyways, I've read many times that it's better to declare Vars, you
don't need globally, not globally, and so this is what I'm always
trying to do, to keep the amount of my global Vars as small as
possible. And in this case it just makes no sense to me, to declare
this font globally as it's needed nowhere else than in this
Event-Handler.
So whatever, if someone can explain me this, I'd be very glad.

thanks in advance...

Gru?,
David.



Mon, 28 Nov 2005 01:32:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB.NET Media Player COM strange problem

2. VB.NET Media Player COM strange problem

3. GDI Printing problem in VB.NET

4. GDI Printing Problem in VB.NET

5. Crystal Reports VB.NET - Printing Problem in a browser

6. strange printing problems

7. strange printing problem

8. Strange printing problem

9. strange text printing problem

10. Strange result in vb.net

11. Random select a record from .mdb works strange in VB.net

12. A STRANGE BUG IN VB.NET TabControl

 

 
Powered by phpBB® Forum Software