none
Visual Basic, Resource Editor not being Read by Form Designer RRS feed

  • Question

  • Okay,

    so, I'm creating a form, but this form will be fully generated by code in a non-design fashion at run time.  So i'm using the designer to create the form, but I will be copying out all the fields and the initializecomponents into my internal form class that will be loaded and run at run-time.  This means, that I cannot have a "MyForm.Resx" file to retain images for buttons and such.  But, granted that this form will exist within the entirety of my ClassLibrary Project, I figured I would load these images into the My.Resources for the class library.  (I"ve set them to embed them in the Resx file, which helps to import the ICO as a Bitmap). 

    now, here is the resource.designer.vb

    Namespace My.Resources
    	
    	'''<summary>
    	'''A strongly-typed resource class, for looking up localized strings, etc.
    	'''</summary>
    	'''<remarks>This class was auto-generated by the FlufFileCodeGenerator
    	'''To add or remove a member, edit your .ResX file, or use the
    	'''VS GUI Resource Editor.</remarks>
    	<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("DynamicCodeGenerators.FlufCodeFileGenerator", "1.1.0.0"),  _
    	 Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
    	 Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(),  _
    	 Global.Microsoft.VisualBasic.HideModuleNameAttribute()>  _
    	Friend Module Resources
    		
    		#Region "-------------::< Fields & Consts >::-------------"
    		Private resourceMan As System.Resources.ResourceManager
    		
    		Private resourceCulture As System.Globalization.CultureInfo
    		#End Region
    		
    		#Region "-------------::< Class Properties >::-------------"
    		'''<summary>
    		'''Returns the cached ResourceManager instance used by this class.
    		'''</summary>
    		<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>  _
    		Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
    			Get
    				If Object.ReferenceEquals(resourceMan, Nothing) Then
    					Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("FlufLib.Resources", GetType(Resources).[Assembly])
    					resourceMan = temp
    				End If
    				Return resourceMan
    			End Get
    		End Property
    		
    		'''<summary>
    		'''Overrides the current thread's CurrentUICulture property for all
    		'''resource lookups using this strongly typed resource class.
    		'''</summary>
    		<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>  _
    		Friend Property Culture() As Global.System.Globalization.CultureInfo
    			Get
    				Return resourceCulture
    			End Get
    			Set
    				resourceCulture = value
    			End Set
    		End Property
    		
    		'''<summary>
    		'''Retrieves embedded Binary Resource value of type System.Drawing.Bitmap
    		'''</summary>
    		Friend ReadOnly Property MoveUp() As Global.System.Drawing.Bitmap
    			Get
    				Return CType(ResourceManager.GetObject("MoveUp", resourceCulture),System.Drawing.Bitmap)
    			End Get
    		End Property
    		
    		'''<summary>
    		'''Retrieves embedded Binary Resource value of type System.Drawing.Bitmap
    		'''</summary>
    		Friend ReadOnly Property MoveDown() As Global.System.Drawing.Bitmap
    			Get
    				Return CType(ResourceManager.GetObject("MoveDown", resourceCulture),System.Drawing.Bitmap)
    			End Get
    		End Property
    		
    		'''<summary>
    		'''Retrieves embedded Binary Resource value of type System.Drawing.Bitmap
    		'''</summary>
    		Friend ReadOnly Property MoveDown16() As Global.System.Drawing.Bitmap
    			Get
    				Return CType(ResourceManager.GetObject("MoveDown16", resourceCulture),System.Drawing.Bitmap)
    			End Get
    		End Property
    		
    		'''<summary>
    		'''Retrieves embedded Binary Resource value of type System.Drawing.Bitmap
    		'''</summary>
    		Friend ReadOnly Property MoveUp16() As Global.System.Drawing.Bitmap
    			Get
    				Return CType(ResourceManager.GetObject("MoveUp16", resourceCulture),System.Drawing.Bitmap)
    			End Get
    		End Property
    		#End Region
    	End Module
    End Namespace
    
    Yes, it may look a little different than usual, as I am using my own Code Generator, but the source is identical to the design of the original ResX file generator included in VS.  now for my form.Designer.vb:

          '
    'MoveDownBtn
    '
    Me.MoveDownBtn.Image = CType(My.Resources.MoveDown16, System.Drawing.Image)
    Me.MoveDownBtn.Location = New System.Drawing.Point(155, 41)
    Me.MoveDownBtn.Name = "MoveDownBtn"
    Me.MoveDownBtn.Size = New System.Drawing.Size(32, 32)
    Me.MoveDownBtn.TabIndex = 10
    Me.MoveDownBtn.UseVisualStyleBackColor = True
    '
    'MoveUpBtn
    '
    Me.MoveUpBtn.Image = CType(My.Resources.MoveUp16, System.Drawing.Image)
    Me.MoveUpBtn.Location = New System.Drawing.Point(155, 3)
    Me.MoveUpBtn.Name = "MoveUpBtn"
    Me.MoveUpBtn.Size = New System.Drawing.Size(32, 32)
    Me.MoveUpBtn.TabIndex = 9
    Me.MoveUpBtn.UseVisualStyleBackColor = True
    I try to view the form in the designer window and 1 of 2 things happens.  If I try to use the designer and set the Image property of these two buttons via the propertygrid, I can choose in the editor to use a "Project Resource" or a "Local Resource"  under the project resources it says (Resources.resx) and the four image names are listed.  I select on and click OK, but the image doesn't appear and the designer.vb file does not contain a line assigning the .Image property of the button.  If i manually add those two lines above, the designer says:
    2 Errors
    The type 'FlufLib.My.Resources.Resources' has no property named 'MoveDown16'.

    The type 'FlufLib.My.Resources.Resources' has no property named 'MoveUp16'.


    What is that?  I don't get a build error, or a compiler error, so what fried the designer's brain?
    Thanks
    Jaeden "Sifo Dyas" al'Raec Ruiner
    "Never Trust a computer. Your brain is smarter than any micro-chip."
    Friday, May 8, 2009 4:28 PM

All replies

  • The My.Resources.MoveUp16 is being translated to FlufLib.My.Resources.Resources.MoveUp16 for some reason.

    If this post is useful, mark it as answer.
    Thursday, May 28, 2009 10:39 AM
  • Okay,

    this is annoying, not only that it keeps happening, and i'm constantly having to manhandle and hack my code, but additionally that every time it happens nobody has an answer to a simple question like this.  Is it a bug/glitch when will the hotfix/service pack come out to fix this?

    Using VS default Resource file Generator, and My own generator this happens quite frequently where a class exists.  I can F12 to the definition directly, but the Forms designer is so retarded it can't find the reference and thinks the file is non-existent

    I've typed them in manually using Intellisense code-completion and still the Forms designer can't find the item and thus blocks me from editing the Form Design.  HOW DO I FIX THIS?

    I've got:

    namespace My.Resources

    module Resources
        property MySTring
    end module

    end namespace

    Namespace My

    Class ResX_Captions
      property MyString
    end class

    end namespace


    I then go to the designer and write in

    SaveDlg.Title = My.Resource.MyString
      or
    SaveDlg.Title = My.ResX_Captions.MyString

    And both get an error from the designer, what up with that?!

    What's the point of Resources if VisualStudio's own system can't use them?

    Thanks
    Jaeden "Sifo Dyas" al'Raec Ruiner
    "Never Trust a computer. Your brain is smarter than any micro-chip."
    Friday, June 19, 2009 8:09 PM