C# 无法通过资源类访问全局资源

C# 无法通过资源类访问全局资源,c#,.net,silverlight,resources,app-globalresources,C#,.net,Silverlight,Resources,App Globalresources,我已经创建了Silverlight业务应用程序,希望使用App_GlobalResources 这些资源位于同一个项目(TestApp.Web)中。正在尝试通过System.resources使用某些资源。在类中不起作用,因为没有列出任何类 我只看到RegistrationDataResources和ValidationErrorResources 也许你有个主意 编辑: 使用资源。te23。提出一个错误。“TestApp.Web.Resources中没有te23类型或名称空间”(翻译成英文)

我已经创建了Silverlight业务应用程序,希望使用App_GlobalResources

这些资源位于同一个项目(TestApp.Web)中。正在尝试通过System.resources使用某些资源。在类中不起作用,因为没有列出任何类

我只看到RegistrationDataResources和ValidationErrorResources

也许你有个主意

编辑: 使用资源。te23。提出一个错误。“TestApp.Web.Resources中没有te23类型或名称空间”(翻译成英文)

“te23”资源的内容(我删除了注释)


}

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

这通常是一个构建问题。验证.resx文件的自定义工具属性是否设置为“GlobalResourceProxyGenerator”


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

我已将resources中的名称空间编辑为TestApp.Web.resources。现在它们被列在资源下。

资源在同一个项目中。(更新了我上面的帖子)我指的是你项目中的参考资料文件夹,我曾经遇到过同样的情况。我没有引用System.Resources DLL。实际上,没有引用System.Resources.DLL。但是我在添加引用窗口中找不到此引用:-/并且右键单击资源文件并查看属性,然后将“构建操作”更改为“嵌入式资源”,使其可用。属性“构建操作”设置为“内容”。将其设置为“嵌入式资源”后,我清理并重建了项目。没有更改。属性已设置为“GlobalResourceProxyGenerator”。@float wait,您在web项目中创建了资源,对吗?您是想从那个项目还是Silverlight项目中访问它们?我是想从web项目中访问它们,而不是从Silverlight项目中访问它们。@float-hm,奇怪,它似乎应该可以工作。让我问你:你在Resource.designer.cs文件中看到了什么?名称空间是否为资源?该类是公共类还是内部类?另一个尝试可能是使用PublicResXFileCodeGenerator作为自定义工具。我已经更新了我的帖子。在那里,您可以看到我的测试资源的designer.cs文件,以及如果我尝试使用它时的错误消息。
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);
        }
    }
}