locked
Resource File not finding correct Language after moving to Separate Project RRS feed

  • Question

  • User-1912941216 posted

    Hi Forum, 

    I though I would be able to get this working, it is half working - but only to the default res file, if I change the language it still returns with the default value. All I have done is moved the resx files to a separate project. Both the resx file are public set to PublicResXFileCodeGenerator and embedded resource - the same as it was when it was working.

    I was not sure how to address the location of the resource file, here is my code below - but it only and always return the default value. The constructor excerpts an ENUM to create the right resource file location, via a SELECT statement (only one option at the moment - this is a test)

    Is the code wrong, or do I somehow need to reference the actual location of the other resource file which is App_GlobalResources\BusinessServiceCheckBoxes.el.resx

    It was defiantly working before I moved to separate project, but I did since write this code to help - so maybe I did something wrong here

    The code works (in a way) as it will return the correct value but always in the default language, but does not return the correct language version of the value

    Do I now need to reference this version of the file in the code - BusinessServiceCheckBoxes.el.resx - but kind of defeats the value of resource files :-)

    Any help or suggestions  would be great

    Kind Regards

    Graham M

    Public Class Go2ResourceAccess
    
        Private BaseUrl As String = "{server location of seperate resources project}"
        Private ResourceLocation As String
        Private rsxr As ResXResourceSet
    
        Sub New(ResourceType As RequiredResource)
            GetResourceUrl(ResourceType)
            rsxr = New ResXResourceSet(ResourceLocation)
        End Sub
    
        Public ReadOnly Property GetResourceValue(key As String) As String
            Get
                Return rsxr.GetString(key)
            End Get
        End Property
    
        Public Enum RequiredResource
            VirtualFolderCheckBoxes = 1
        End Enum
    
        Private Sub GetResourceUrl(ResourceType As RequiredResource)
            Select Case ResourceType
                Case RequiredResource.VirtualFolderCheckBoxes
                    ResourceLocation = BaseUrl & "App_GlobalResources\BusinessServiceCheckBoxes.resx"
            End Select
    
        End Sub
    
    End Class

    Wednesday, February 28, 2018 7:46 AM

Answers

  • User-1912941216 posted

    Hi All, 

    13 Hours later I finally got it to work - it is easy

    DIm answer = {namespace}.{ResourceFileClassName}.ResourceManager.Getstring("name")
    Public ReadOnly Property GetResourceValue(key As StringAs String
        Get
            Return {AppNameSpace}.Resource.CheckBoxes.VirtualFolderCheckBoxes.ResourceManager.GetString(key)
        End Get
    End Property

    Hope this helps somebody one day

    Graham

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 28, 2018 9:42 PM