views:

313

answers:

1

Developing a multilingual application in VB.Net 2008, Im able to add resources to forms and create a multilingual forms depending on uiculture. On reading Msdn on creating the multilingual string values for messagebox contents, have added the .resource file to the project files path as specified. There is no error on compilation but throws the MissingManifestResourceException error

Dim rm As ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("strFormResources", ".", Nothing) Dim ci As CultureInfo ci = New CultureInfo("fr-FR") MessageBox.Show(rm.GetString("sample1", ci))

Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: strFormResources locationInfo: fileName: strFormResources.resources

There is strFormResources.resources and strFormResources.fr-FR.resources in Resources of the project. I have searched for this error details but could not find a solution. What am i doing wrong or is there any other method for displaying multilingual strings in the messagebox.

Thanks in advance

A: 

The lblBrowsefoldertoputconvertedfiles is a hint perhaps. You are supposed to pass the string resource name, not the name of the directory that contains the resource.

To do it "properly", be sure to take advantage of the My.Resources feature. Proceed as follows:

  • Project + Add New Item, General, Resources File
  • Name it Resources.fr-FR.resx and click Add
  • The string resource editor automatically opens. Add the strings that you've got in your original string table, now using French as the language.
  • Compile.
  • Look in your project's bin\Debug folder and verify that you now see the satellite assembly. It should be stored in the fr-FR directory with the project.resources.dll name.

Test this by dropping a button on your form and writing this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    System.Threading.Thread.CurrentThread.CurrentUICulture = _
        System.Globalization.CultureInfo.GetCultureInfo("fr-FR")
    MessageBox.Show(My.Resources.String1)
End Sub
Hans Passant
have created a string resource with name "sample1" and put the string resource name "sample1". But it repeats me the same error.
Naresh
@Naresh: post updated, showing how to use My.Resources
Hans Passant
Thanks , hans Passant, got worked out for me ...
Naresh