代码之家  ›  专栏  ›  技术社区  ›  Unbreakable

无法在VS Web解决方案中添加Resx文件

  •  0
  • Unbreakable  · 技术社区  · 7 年前

    1. 已创建空的Asp.net解决方案。
    2. 添加了具有基本名称值内容的Resx文件。
    3. protected void Page_Load(object sender, EventArgs e) { ResourceManager rm = new ResourceManager("UsingRESX.Resource1", Assembly.GetExecutingAssembly()); String strWebsite = rm.GetString("Website", CultureInfo.CurrentCulture); // here I get the exception String strName = rm.GetString("Name"); form1.InnerText = "Website: " + strWebsite + "--Name: " + strName; }

    但当我运行代码时,会出现异常:

       Could not find any resources appropriate for the specified
     culture or the neutral culture.  Make sure "UsingRESX.Resource1.resources"
     was correctly embedded or linked into assembly "WebApplication1" at compile 
    time, or that all the satellite assemblies required are loadable and fully signed.
    

    我在本练习中遵循的教程: Read Resx FIle

    所以我尝试的解决方案是: SO Solution

    enter image description here

    enter image description here

    enter image description here

    1 回复  |  直到 7 年前
        1
  •  1
  •   Eric J    7 年前

    尝试添加

    var assembly = Assembly.GetExecutingAssembly();
    assembly.GetManifestResourceNames();
    

    并设置断点。这将列出所有嵌入的资源。确保你有正确的名字。有时资源路径并不完全明显。