Loading...
 

History: UnexpectedUseOfResources

Preview of version: 2

Unexpected use of resources by the forms designer

Over a long period, some users have reported problems with code generated in the function InitializeComponent(), looking something like this:

this.labelX9.BackgroundStyle.Class = global::YourProject.MultiLang._668;

The reference to MultiLang obviously implicates the Multi-Language Add-In, but the code in InitializeComponent() is neither generated nor modified by the Add-In. This effect has always baffled me.

Now I think I know what is happening, and I can illustrate it with a sample program. This sample contains several parts, which I will try to describe in detail

Sample Program

This sample defines

  • a Class
  • a UserControl which exposes a property of that class
  • a Form which uses the UserControl
  • a resource file

I have made the sample in VB, but it could just as easily be in C#. I am sure that there is no difference.

The class

Imports System.ComponentModel

<TypeConverterAttribute(GetType(ExpandableObjectConverter))> _
Public Class MyObject

  Private mEmpty      As String = ""
  Private mOne        As String = "One"
  Private mTwo        As String = "Two"

  <Localizable(True)> _
  <Browsable(True)> _
  Public Property Empty as String
    Get
      Return mEmpty
    End Get
    Set(ByVal value As String)
      mEmpty = value
    End Set
  End Property

  <Localizable(True)> _
  Public Property One as String
    Get
      Return mOne
    End Get
    Set(ByVal value As String)
      mOne = value
    End Set
  End Property

  Public Property Two as String
    Get
      Return mTwo
    End Get
    Set(ByVal value As String)
      mTwo = value
    End Set
  End Property

End Class

History

Information Version
Wed 15 of Sep, 2010 19:12 GMT Phil 20
Fri 04 of Jun, 2010 20:19 GMT Phil 19
Fri 04 of Jun, 2010 19:25 GMT Phil 18
Fri 04 of Jun, 2010 19:04 GMT Phil 17
Fri 04 of Jun, 2010 18:47 GMT Phil 16
Fri 04 of Jun, 2010 18:46 GMT Phil 15
Fri 04 of Jun, 2010 18:41 GMT Phil 14
Fri 04 of Jun, 2010 18:33 GMT Phil 13
Fri 04 of Jun, 2010 18:32 GMT Phil 12
Fri 04 of Jun, 2010 17:40 GMT Phil 11
Fri 04 of Jun, 2010 17:36 GMT Phil 10
Fri 04 of Jun, 2010 17:28 GMT Phil 9
Fri 04 of Jun, 2010 17:26 GMT Phil 8
Fri 04 of Jun, 2010 17:19 GMT Phil 7
Fri 04 of Jun, 2010 16:58 GMT Phil 6
Fri 04 of Jun, 2010 16:53 GMT Phil 5
Fri 04 of Jun, 2010 16:43 GMT Phil 4
Fri 04 of Jun, 2010 16:35 GMT Phil 3
Fri 04 of Jun, 2010 16:24 GMT Phil 2
Fri 04 of Jun, 2010 13:06 GMT Phil 1