无法通过Resources类访问全局资源

时间:2012-07-05 07:51:31

标签: c# .net silverlight resources app-globalresources

我创建了一个Silverlight业务应用程序,并希望使用App_GlobalResources。

资源位于同一个项目(TestApp.Web)中。试图通过System.Resources使用一些资源。在一个类中不起作用,因为没有列出的类。

我只看到RegistrationDataResources和ValidationErrorResources。

也许你有个主意?

编辑: 使用Resources.te23。提出错误。 “TestApp.Web.Resources中没有Type或Namspace te23”(翻译成英文)

“te23”资源的内容(我删除了评论)。

namespace Resources {
using System;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "10.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class te23 {
    private static global::System.Resources.ResourceManager resourceMan; 
    private static global::System.Globalization.CultureInfo resourceCulture;

    [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    internal te23() {
    }
   [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
    internal static global::System.Resources.ResourceManager ResourceManager {
        get {
            if (object.ReferenceEquals(resourceMan, null)) {
                global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Resources.te23", global::System.Reflection.Assembly.Load("App_GlobalResources"));
                resourceMan = temp;
            }
            return resourceMan;
        }
    }
    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
    internal static global::System.Globalization.CultureInfo Culture {
        get {
            return resourceCulture;
        }
        set {
            resourceCulture = value;
        }
    }
    internal static string test {
        get {
            return ResourceManager.GetString("test", resourceCulture);
        }
    }
}

}

3 个答案:

答案 0 :(得分:0)

只是想一想,您是否有对特定库的库引用?

答案 1 :(得分:0)

这通常是构建问题。验证.resx文件的 Custom Tool 属性是否设置为“GlobalResourceProxyGenerator”。

(请注意,您可以使用 Resources.MyResxFile.ResourceName 访问资源。)

答案 2 :(得分:0)

我已经将资源中的名称空间编辑为TestApp.Web.Resources。现在他们在资源下倾听。