 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Adam Guy Guest
|
Posted: Mon Sep 13, 2004 3:01 am Post subject: Odd crash created by COM server created in BCB |
|
|
Hi,
Our COM server created in BCB 6 is causing a very strange crash for some
clients in C#.
Only in C# under MS Developer Studio, we find that when a client programmer
changes the font of (for example) a label in a form that is created
dynamically at run time - at the point at run-time when the font object is
actually created an arithmetic exception is generated!
The code that is created in the InitializeComponent() function for the label
is like:
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
Looks normal enough - but when executed we get:
"An unhandled exception of type 'System.ArithmeticException' occurred in
system.drawing.dll Additional information: Overflow or underflow in the
arithmetic operation."
When we comment out the creation of our COM component, no problem.
Our COM server has absolutely no "font" interface elements at all. The COM
server works fine in all environments (Delphi, VB, MSVC++, BCBC++, etc.)
under exactly the same conditions.
Any idea where I should start looking - this is a real mystery.
Regards,
Zack.
|
|
| Back to top |
|
 |
Marcelo R. Lopez, Jr. Guest
|
Posted: Thu Sep 16, 2004 7:35 pm Post subject: Re: Odd crash created by COM server created in BCB |
|
|
Adam Guy wrote:
| Quote: | Hi,
Our COM server created in BCB 6 is causing a very strange crash for some
clients in C#.
Only in C# under MS Developer Studio, we find that when a client programmer
changes the font of (for example) a label in a form that is created
dynamically at run time - at the point at run-time when the font object is
actually created an arithmetic exception is generated!
The code that is created in the InitializeComponent() function for the label
is like:
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
Looks normal enough - but when executed we get:
"An unhandled exception of type 'System.ArithmeticException' occurred in
system.drawing.dll Additional information: Overflow or underflow in the
arithmetic operation."
When we comment out the creation of our COM component, no problem.
Our COM server has absolutely no "font" interface elements at all. The COM
server works fine in all environments (Delphi, VB, MSVC++, BCBC++, etc.)
under exactly the same conditions.
Any idea where I should start looking - this is a real mystery.
Regards,
Zack.
I've developed some OCX's in BCB that some colleagues have used in their |
VS.NET programs, but not that had UI
elements within them. I think what "might" be happening, is that COM
Interop doesn't know how to serial a
System.Drawing.Font into a Graphics::TFont *
(What you created ) ( What the TLabel was expecting )
What I would do in your case, is create interfaces in the OCX like such
MyObj::SetLabelFont([in]BSTR * Name, [in] double pointSize, [in] int weight, etc..etc );
You create a TFont internally, set it's necessary properties..then assign it to the Label,
and let the Label's Font object serialize it from there....but that's just me..there's probably
more elegant ways of doing this.
Marcelo
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|