?
Solved

.net Compact Framework: Assigning an & to a label throws out of memory exception

Posted on 2007-11-26
9
Medium Priority
?
705 Views
Last Modified: 2013-12-05
I'm having a problem in my .net CF 2.0 application.

When I open a specific form I do a search (via web service) and find a client and all of their memberships. If I find a membership, I update the UI to display start date, pass description etc...

I was testing to make sure it works with all special characters (&^@#!/\^) etc and I've found that when I assign an ampersand (&) to any of the labels on the form, the memory usage just grows and grows until an outofmemory exception is thrown.

This does not happen on any other form (from what I can tell) and I can't reproduce it in a basic application with just one form.

Another thing to note is that this form is shown as a dialog.

The code I'm running:

lblPassPlan.text = "Plan: "
lblPassPlan.text = lblPassPlan.text & "Gym && Swimming Pool"   <-- I've tried this with one ampersand as well, same thing. It throws the outofmemory exception on this line.

Here is the message from the exception:

            StackTrace      "at System.PInvoke.EE.FastAllocateString()
at System.String.GetStringForStringBuilder()
at System.String.GetStringForStringBuilder()
at System.Text.StringBuilder.GetNewString()
at System.Text.StringBuilder.Append()
at System.String.ReplaceOrdinal()
at System.String.Replace()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.lblPassPlan_TextChanged()
at System.Windows.Forms.Control.OnTextChanged()
at System.Windows.Forms.Control.set_Text()
at ClassWireless.formValidation.UpdateUI()
at ClassWireless.formValidation.GetClientPass()
at ClassWireless.formValidation.btnSearch_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Button.OnClick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterModalDialog()
at System.Windows.Forms.Form.ShowDialog()
at ClassWireless.formMain.picMemberships_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Control.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at ClassWireless.formMain.Main()
"      String


0
Comment
Question by:BlahMatt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 20352274
try
lblPassPlan.text + "Gym && Swimming Pool"
0
 

Author Comment

by:BlahMatt
ID: 20352303
Using + instead of & for the concatenation  throws the same exception.
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 20352367
Dim NewLabel as string = lblPassPlan.text + "Gym && Swimming Pool"

lblPassPlan.text = NewLabel
0
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 

Author Comment

by:BlahMatt
ID: 20352432
OK... it doesn't throw an oom exception when I assign the string to a variable first

However it takes an abnormally long amount of time on that line of code (Assigning to the label) and then the labels text property is "" so the label doesn't appear.
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 20352457
Dim NewLabel as string = lblPassPlan.text & "Gym && Swimming Pool"
lblPassPlan.Text = ""
lblPassPlan.text = NewLabel

0
 

Author Comment

by:BlahMatt
ID: 20352648
Assigning the labels text = "" didn't change anything from what I can tell.

Same behavior...

Dim sNewLabel As String = lblPassPlan.text & "Gym && Swimming Pool"
lblPassPlan.text = ""
lblPassPlan.text = sNewLabel (where sNewLabel = "Plan: Gym && Swimming Pool")

Here lblPassPlan.text is still ""
0
 
LVL 48

Accepted Solution

by:
Mikal613 earned 1000 total points
ID: 20352685
and if you do the same with a textbox ?

Can you create a new label and see what happens?
0
 

Author Comment

by:BlahMatt
ID: 20353114
With a textbox it works and creating a new label worked.

I'm not certain what properties are different on that label that would cause that though. I can't find any.

I'm ok with just creating new labels though. Thanks Mikal!
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 20353128
No problem
0

Featured Post

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question