C#-如何从自定义资源提供程序读取字符串值?

C#-如何从自定义资源提供程序读取字符串值?,c#,resources,localization,C#,Resources,Localization,我通过以下链接中的指导原则创建了自定义资源提供程序: 在.aspx页面上,我使用了以下代码,它运行良好: <asp:Literal ID="ltlFoo" runat="server" Text="<%$ Resources:SomeText %>" /> 问题是我不知道如何实例化资源管理器。 任何帮助都将不胜感激 编辑: 我使用了以下代码,效果非常好: string foo = (string)GetGlobalResourceObject("", "SomeTe

我通过以下链接中的指导原则创建了自定义资源提供程序:

在.aspx页面上,我使用了以下代码,它运行良好:

<asp:Literal ID="ltlFoo" runat="server" Text="<%$ Resources:SomeText %>" /> 
问题是我不知道如何实例化资源管理器。
任何帮助都将不胜感激

编辑:
我使用了以下代码,效果非常好:

string foo = (string)GetGlobalResourceObject("", "SomeText");

有什么理由不使用该代码吗?

因此,您的资源管理器应该有一个名称,并且您应该能够执行类似于以下内容的操作

 // Create a resource manager to retrieve resources.
        ResourceManager rm = new ResourceManager("items", 
            Assembly.GetExecutingAssembly());


 // Retrieve the value of the string resource named "welcome".
 // The resource manager will retrieve the value of the  
 // localized resource using the caller's current culture setting.
 String foo = rm.GetString("SomeText");

因此,您的资源管理器应该有一个名称,并且您应该能够执行类似于以下内容的操作

 // Create a resource manager to retrieve resources.
        ResourceManager rm = new ResourceManager("items", 
            Assembly.GetExecutingAssembly());


 // Retrieve the value of the string resource named "welcome".
 // The resource manager will retrieve the value of the  
 // localized resource using the caller's current culture setting.
 String foo = rm.GetString("SomeText");