<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="trLanguage.WebForm1" %>
while executing the code
System.Resources.MissingManifestResourceException: 'Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "trLanguage.App_GlobalResources.Lang.resources" was correctly embedded or linked into assembly "trLanguage" at compile time, or that all the satellite assemblies required are loadable and fully signed.'
we have added added resx file also in App_GlobalResources folder.Please check the issue.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection.Emit;
using System.Reflection;
using System.Resources;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace trLanguage
{
public partial class WebForm1 : System.Web.UI.Page
{
ResourceManager rm;
CultureInfo ci;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Lang"] == null)
{
Session["Lang"] = Request.UserLanguages[0];
}
if (!IsPostBack)
{
LoadString(); //This function is used to translate languages based on selected languages
}
}
protected void ddLang_SelectedIndexChanged(object sender, EventArgs e) //this event for showing selected language.
{
Session["Lang"] = ddLang.SelectedValue;
LoadString();
}
private void LoadString()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["Lang"].ToString());
rm = new ResourceManager("trLanguage.App_GlobalResources.Lang", Assembly.GetExecutingAssembly()); //we configure resource manages for mapping with resource files in App_GlobalResources folder.
ci = Thread.CurrentThread.CurrentCulture;
lblusername.Text = rm.GetString("username", ci);//same as//
lblpwd.Text = rm.GetString("password", ci);//same as//
}
}
}