0

I am using VS2015 and have a project called "CultureTest" (this is my project name and root namespace). I created a folder in my project "Languages" and in this folder created a new resource item named "English.resx". I only have one string in there now called "Start" with the value being the same.

In my VB.NET code I have the following

Imports System.Globalization
Imports System.Reflection
Imports System.Resources

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim ci As CultureInfo = New CultureInfo("en-US")
        Dim rm As ResourceManager = New ResourceManager("CultureTest.Languages.English", Assembly.GetExecutingAssembly())

        MessageBox.Show(rm.GetString("Start", ci))
    End Sub
End Class

Every time I run this, I get the following error:

'rm.getstring("Start",ci)' threw an exception of type 'System.Resources.MissingManifestResourceException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233038
HelpLink: Nothing
InnerException: Nothing
Message: "Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure ""CultureTest.Languages.English.resources"" was correctly embedded or linked into assembly ""CultureTest"" at compile time, or that all the satellite assemblies required are loadable and fully signed."
Source: "mscorlib"
StackTrace: "   at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)" & vbCrLf & "   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)" & vbCrLf & "   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)" & vbCrLf & "   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)" & vbCrLf & "   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)"
TargetSite: {Void HandleResourceStreamMissing(System.String)}

For the life of me I cannot seem to read my resource file. What am I doing wrong? Any help and examples would be greatly appreciated!

Kind Regards

DataCrypt
  • 307
  • 1
  • 5
  • 15
  • have you set the resource file to be included in the build via it's properties? – bilpor Jun 27 '16 at 16:23
  • 1
    Yes, in fact I just figured out that the ResourceManager needed be to "RootNamespace.ResxFilename" and it worked! I had ".Languages" in there for the folder and that was the issue. Curious though, I'm using this to have my application in different languages and am wondering if this is the correct way to do it? A string in each language for everything on-screen. I see the form has a Localization property and not sure how the CultureInfo is really required in my example code. Perhaps there is a better way of doing it? – DataCrypt Jun 27 '16 at 18:40

0 Answers0