473,387 Members | 1,597 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,387 software developers and data experts.

Toolstrip Exception - bad .NET?

I have a program that is crashing on some machines (at a client of
ours). I have determined that it goes down on this line of code:

ToolStrip x = new ToolStrip();

I created a simple test app that only performs this one line of code.
It throws an exception so I know the problem is not caused by
something in my code. It seems like there is a problem with .NET. We
have tried uninstalling and reinstalling .NET 2, but it doesn't help.

Please, please, please, does anybody have any ideas? The following is
the exception info from my test app...

"Parameter is not valid"

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Parameter is not valid.
at System.Drawing.Font.GetHeight(Graphics graphics)
at System.Drawing.Font.get_SizeInPoints()
at System.Drawing.SystemFonts.FontInPoints(Font font)
at System.Drawing.SystemFonts.get_MenuFont()
at System.Windows.Forms.ToolStripManager.get_DefaultF ont()
at System.Windows.Forms.ToolStripItem.get_Font()
at
System.Windows.Forms.ToolStripItemInternalLayout.C ommonLayoutOptions()
at
System.Windows.Forms.ToolStripDropDownButton.ToolS tripDropDownButtonInternalLayout.CommonLayoutOptio ns()
at System.Windows.Forms.ToolStripItemInternalLayout.G etLayoutData()
at System.Windows.Forms.ToolStripItemInternalLayout.P erformLayout()
at System.Windows.Forms.ToolStripDropDownItem.OnBound sChanged()
at System.Windows.Forms.ToolStripItem.SetBounds(Recta ngle bounds)
at System.Windows.Forms.ToolStripOverflowButton.SetBo unds(Rectangle
bounds)
at System.Windows.Forms.ToolStripItem.set_Size(Size value)
at System.Windows.Forms.ToolStrip.get_OverflowButton( )
at
System.Windows.Forms.ToolStripSplitStackLayout.get _OverflowButtonSize()
at
System.Windows.Forms.ToolStripSplitStackLayout.Lay outHorizontal()
at
System.Windows.Forms.ToolStripSplitStackLayout.Lay outCore(IArrangedElement
container, LayoutEventArgs layoutEventArgs)
at System.Windows.Forms.Layout.LayoutEngine.Layout(Ob ject
container, LayoutEventArgs layoutEventArgs)
at System.Windows.Forms.Control.OnLayout(LayoutEventA rgs levent)
at System.Windows.Forms.ScrollableControl.OnLayout(La youtEventArgs
levent)
at System.Windows.Forms.ToolStrip.OnLayout(LayoutEven tArgs e)
at System.Windows.Forms.Control.PerformLayout(LayoutE ventArgs args)
at System.Windows.Forms.Control.PerformLayout()
at System.Windows.Forms.Control.ResumeLayout(Boolean performLayout)
at System.Windows.Forms.ToolStrip..ctor()
at WindowsApplication2.Form1.button1_Click(Object sender, EventArgs
e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
WindowsApplication2
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/NextGen/WindowsApplication2.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.832 (QFE.050727-8300)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />

Oct 9 '07 #1
6 2768
On Oct 9, 1:05 pm, Mike <MLM...@hotmail.comwrote:
I have a program that is crashing on some machines (at a client of
ours). I have determined that it goes down on this line of code:

ToolStrip x = new ToolStrip();

I created a simple test app that only performs this one line of code.
Well, it looks like this is happening within a button click, which
suggests that it performs more than that one line of code.

Could you post a short but complete program demonstrating the problem?
See http://pobox.com/~skeet/csharp/complete.html for more details.

Jon

Oct 9 '07 #2
Mike <ML****@hotmail.comwrote:
Thanks for the quick response. You are correct. What I created was a
form application with a single button. The handler for the button
click only does the one line of code.

Since the time when I retrieved these exception details, I changed the
app to make it simpler so I don't have that exact code. The new test
app runs the bad line of code in the constructor within a try...catch
and shows a message on the form based on the results. I get
"succeeded" on my system, but "failed" on the client's system. Here is
the new code...
That code will always fail - it doesn't run the InitializeComponent
code in the designer file.

However, I wonder whether your client's machine doesn't have the
appropriate font installed. On my box it's using "Segoe UI" as the font
name - you might want to check whether that's installed on your
client's machine.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 9 '07 #3
Thanks for the reply. I'll check the font.

BTW, I'm a little confused by your comment that this code will never
work. It works on my machine. That code is straight from what dev
studio gives me when I create a new windows app project.

On Oct 9, 2:08 pm, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
Mike <MLM...@hotmail.comwrote:
Thanks for the quick response. You are correct. What I created was a
form application with a single button. The handler for the button
click only does the one line of code.
Since the time when I retrieved these exception details, I changed the
app to make it simpler so I don't have that exact code. The new test
app runs the bad line of code in the constructor within a try...catch
and shows a message on the form based on the results. I get
"succeeded" on my system, but "failed" on the client's system. Here is
the new code...

That code will always fail - it doesn't run the InitializeComponent
code in the designer file.

However, I wonder whether your client's machine doesn't have the
appropriate font installed. On my box it's using "Segoe UI" as the font
name - you might want to check whether that's installed on your
client's machine.

--
Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 9 '07 #4
Mike <ML****@hotmail.comwrote:
Thanks for the reply. I'll check the font.

BTW, I'm a little confused by your comment that this code will never
work. It works on my machine. That code is straight from what dev
studio gives me when I create a new windows app project.
No, it's not. Check the constructor. You got rid of the call to
InitializeComponent - indeed, it will throw a NullReferenceException
because lblResults is still null.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 9 '07 #5
My mistake. I thought you meant that the designer can't have the
InitializeComponent function.

The call is in my test app. I made a mistake when I copied the code
that caused it to be omitted. The correct constructor follows...

public Form1()
{
InitializeComponent();

try
{
ToolStrip x = new ToolStrip();
}
catch (Exception)
{
lblResults.Text = "FAILED";
return;
}
lblResults.Text = "SUCCEEDED";
}
On Oct 9, 5:58 pm, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
Mike <MLM...@hotmail.comwrote:
Thanks for the reply. I'll check the font.
BTW, I'm a little confused by your comment that this code will never
work. It works on my machine. That code is straight from what dev
studio gives me when I create a new windows app project.

No, it's not. Check the constructor. You got rid of the call to
InitializeComponent - indeed, it will throw a NullReferenceException
because lblResults is still null.

--
Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 10 '07 #6
Thanks Jon! I just heard back from our client that the font was the
problem. Windows thought the font was installed because it was in the
registry but it really was not there. Deleting the registry key
allowed the font to reinstall and everything is OK now.

On Oct 9, 1:08 pm, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
Mike <MLM...@hotmail.comwrote:
Thanks for the quick response. You are correct. What I created was a
form application with a single button. The handler for the button
click only does the one line of code.
Since the time when I retrieved these exception details, I changed the
app to make it simpler so I don't have that exact code. The new test
app runs the bad line of code in the constructor within a try...catch
and shows a message on the form based on the results. I get
"succeeded" on my system, but "failed" on the client's system. Here is
the new code...

That code will always fail - it doesn't run the InitializeComponent
code in the designer file.

However, I wonder whether your client's machine doesn't have the
appropriate font installed. On my box it's using "Segoe UI" as the font
name - you might want to check whether that's installed on your
client's machine.

--
Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 29 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fredrik Melin | last post by:
2005 RTM: Have a form, quite a few control, (full form of stuff, tab pages, buttons, labels, text-controls etc) Selecting controls, going in and out between code/design view is a little bit...
2
by: VBTricks.de.vu Webmaster | last post by:
Hello, I'm still reimplementing the GUI of my app using the new toolstrips. My current problem is to autosize a combobox to the available with in the parent toolstrip. There are some buttons...
0
by: gene kelley | last post by:
I'm migrating/rewriting one of my VB6 apps to VB2005. In the process, I'm trying to avoid using third party activex controls used in the VB6 project. One of the third party controls in the VB6...
1
by: Alex Clark | last post by:
Hi all, I'm using the ToolStrip in .NET 2.0, and I can't seem to find a way to change the size of it. What I want is a toolbar the size of the IE toolbar, preferably with text below images if...
1
by: PJ6 | last post by:
This would have been better if I could have just implemented an interface or two to author my own toolstrip controls... but no, I have to inherit from just the existing ones. Fine, I thought... ...
0
by: Jon Davis | last post by:
I'm taking the items from a menustrip of a control and moving them to the parent form's menustrip: private void TakeMenus(AdminControl ac) { foreach (Control c in ac.Controls) { if (c is...
0
by: Anand Ganesh | last post by:
Hello Everybody, I am using the ToolStrip Control in .NET 2.0. I am also using a ToolStripContainer Control. I want to know how to retain the position of the ToolStrip Control in the...
0
by: Martijn Mulder | last post by:
The ToolStrip on top of my form is to small. I want to increase its height. Simply setting the Height-property doesn't change the height, though. So I tried to place the ToolStrip in a...
1
by: Tom P. | last post by:
It's kind of hard to explain (so if you need more just ask) and any help would be greatly appreciated. I am writing a side-by-side file manager. On each side I have a DropDownButton that holds...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.