0
votes

I have a resx file called Resources1.resx and this file is location in the class library Test.WebControls, this is how i am trying to get the values from the resx file using vb.net.

Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports API.HTML.Controls
Imports API

Public Class BaseCallbackPageControl
    Inherits Controls.BasePageControls

    Private _ResourceManager As Resources.ResourceManager

    Public Function GetResource(ByVal key As String) As String

        If Me._ResourceManager Is Nothing Then
            Me._ResourceManager = New Resources.ResourceManager("Resource1.resx", Reflection.Assembly.GetExecutingAssembly)
        End If

        Return Me._ResourceManager.GetString(key)

    End Function

End Class

But I keep getting an error "Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Resource1.resx.resources" was correctly embedded or linked into assembly "Test.WebControls" at compile time, or that all the satellite assemblies required are loadable and fully signed."

The resx file is embedded as resource as well.

What am I doing wrong?

1

1 Answers

1
votes

If you added the resource file through the standard mechanism, then it should have automatically created a designer file which you can use to directly access the resources and or a resource manager specific to that resource file.

For example, assuming that there is a string resource in this file called string1, you should be able to access it directly with:

Resources1.String1

In addition, you can ask the resources' code to instantiate a resource manager and then use that for your operations:

Resources1.ResourceManager.<do some work>