无法访问资源(resx)文件

时间:2016-06-27 16:09:39

标签: .net vb.net resources resx resourcemanager

我正在使用VS2015并有一个名为" CultureTest" (这是我的项目名称和根命名空间)。我在我的项目中创建了一个文件夹" Languages"并在此文件夹中创建了一个名为" English.resx"的新资源项。我现在只有一个字符串,现在称为"开始"价值相同。

在我的VB.NET代码中,我有以下内容

Imports System.Globalization
Imports System.Reflection
Imports System.Resources

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim ci As CultureInfo = New CultureInfo("en-US")
        Dim rm As ResourceManager = New ResourceManager("CultureTest.Languages.English", Assembly.GetExecutingAssembly())

        MessageBox.Show(rm.GetString("Start", ci))
    End Sub
End Class

每次运行时,都会出现以下错误:

'rm.getstring("Start",ci)' threw an exception of type 'System.Resources.MissingManifestResourceException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233038
HelpLink: Nothing
InnerException: Nothing
Message: "Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure ""CultureTest.Languages.English.resources"" was correctly embedded or linked into assembly ""CultureTest"" at compile time, or that all the satellite assemblies required are loadable and fully signed."
Source: "mscorlib"
StackTrace: "   at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)" & vbCrLf & "   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)" & vbCrLf & "   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)" & vbCrLf & "   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)" & vbCrLf & "   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)"
TargetSite: {Void HandleResourceStreamMissing(System.String)}

对于我的生活,我似乎无法阅读我的资源文件。我究竟做错了什么?任何帮助和示例将不胜感激!

亲切的问候

0 个答案:

没有答案