Problem with Globalization on VS 2017

Hi.
I trying to do the multi language application on Windows 10, Visual Studio 2017. The working code I used before stop to work for some reason.
using System;
using System.Windows.Forms;
using System.Resources;
using System.Globalization;


namespace Language
{
    public partial class Form1 : Form
    {
        ResourceManager res_man;    // declare Resource manager to access to specific cultureinfo
        CultureInfo cul;            //declare culture info
        string test_string;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            res_man = new ResourceManager("Language.Resource.Res", typeof(Form1).Assembly);
            switch_language();
        }

        private void switch_language()
        {
             cul = CultureInfo.CreateSpecificCulture("eng");        //create culture for English
             test_string = res_man.GetString("Test", cul);
            label1.Text = test_string;

        }
    }
}
I downloaded project from www.codeproject.com and it gives the same error:
System.Resources.MissingManifestResourceException: 'Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "Language.Resource.Res.resources" was correctly embedded or linked into assembly "Language" at compile time, or that all the satellite assemblies required are loadable and fully signed.'

What I do wrong?
LVL 1
mastiSoftAsked:
Who is Participating?
 
mastiSoftConnect With a Mentor Author Commented:
Hi.
I found the problem and now it's working. By changing properties of the language resource file "Copy to Output Directory" to: COPY ALWAYS.
I don't use the globalization now but :
using System.Resources;
3. Add declaration
namespace tcp_fftw
{
    public partial class Form1 : Form
    {
     //path to the language file:
        static string resxFile;
        ResXResourceSet resxGet;
        string CaptionFile;

4. Add to source code:

 // last selected language file
            string lng = Properties.Settings.Default.Language;
            if (lng=="eng")//english
            {
                resxFile = @".\eng.resx";
            }
            if (lng=="rus")//Russian
            {
                resxFile = @".\rus.resx";
            }

            resxGet = new ResXResourceSet(resxFile);

             
            CaptionFile = resxGet.GetString("Notconnected"); //here select the infor on the language file
            tlStatus.Text = CaptionFile;// "Not connected";// show text
0
 
Robberbaron (robr)Commented:
not sure of the real reason but looking at https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.createspecificculture(v=vs.110).aspx   "eng" does not appear to be a recognised name.


should it be "en-US"  or "en-UK"

see snippet4 for MS way of changing culture.
https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-4
1
 
mastiSoftAuthor Commented:
the suggestions I received didn't help but I found my own solution .
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.