UPDATE 26 June 2007: Tom found a "fix" for this. See the end of this post.
Earlier this week I mentioned a bug in Visual Studio 2008:
That's all well and good when the code spitter works correctly. When it doesn't, you get to deal with weird problems. Lately I've had two rounds of a problem with a large project converted from VB.NET in VS 2003 to VB.NET in VS 2008. Microsoft provides conversion utilities built into VS 2008 and they seemed to run OK, but I and another coworker have hit the same problem in our UIs.
Tom and I had each seen this a few more times by the end of the week and we could not find a way around it. Our most recent hope was that rebuilding the forms from scratch (gawd that'll be a lot of work) would stop this from happening.
It didn't.
We've narrowed our understanding of the symptom down to the point where we know that as soon as we do anything that allows the IDE to update the designer information for a form, any RichTextBox on the form has its Text property assigned to an expression that does not exist. Here's an example I just reproduced. First, the correct code:
Me.tbIdentity.DetectUrls = False
resources.ApplyResources(Me.tbIdentity, "tbIdentity")
Me.tbIdentity.Name = "tbIdentity"
Me.tbIdentity.Text = ""
And the error code, note that tbIdentity.Text is changed:
Me.tbIdentity.DetectUrls = False
resources.ApplyResources(Me.tbIdentity, "tbIdentity")
Me.tbIdentity.Name = "tbIdentity"
Me.tbIdentity.Text = Global.Cincom.KnowledgeMaster.EventMasterFull.c_KMDisplayTextBox.rtfText_Text
Too weird. I keep changing the value assigned to Me.tbIdentity.Text to an empty string when I check the code in, and Tom deletes the line. Touch the form in a later editing session and it breaks again. Googling has been unproductive, the base error message "blah is not a member of blah" is too common, and words like member really throw off the search results when it comes to programming forums where the Google crawler bot is "not a member of this forum".
This only seems to happen to stock RichTextBoxes, so maybe when we convert our apps to use DevExpress widgets, this will go away. I hope so. It's a huge pain.
UPDATE: A circumvention has been found.
Tom noticed that this was only happening with Rich Text Boxes where the initial text is an empty string. He experimented and found that setting any other value for the initial text will prevent Visual Studio from damaging the generated code. Of course, we really want these fields to be initialized to String.Empty, so we're adding explicit updates in the Form's constructor or (my preference) in the Form Load event.
Technorati Tags:
programming, software, visualstudio, 2008, vs2008, bugs, generated-code, richtextbox