How do I get all th resources dynamically from my current assembly? I have tried two methods, GetManifestResourceNames and GetResourceSet with no success. I am comfortable with solutions in VB.net or C#.
First Method
This first method only returns an array of length 1 with this value "MyNameSpace.Resources.resource". The problem is that there are more than 1 resource in this file.
Dim ca As Assembly = Assembly.GetExecutingAssembly
Dim rn() As String = CurrentAssembly.GetManifestResourceNames()
Second Method
Dim ca As Assembly = Assembly.GetExecutingAssembly
Dim crm As New ResourceManager("", ca)
''//Dim CurrentResourceManager As New ResourceManager(_
"MyNamespace.Resources.resources", CurrentAssembly)
''//Dim CurrentResourceManager As New ResourceManager( _
"My.Resources", CurrentAssembly)
Dim rs As ResourceSet = CurrentResourceManager.GetResourceSet(CultureInfo.CurrentCulture, True, True)
Dim rs As ResourceSet = crm.GetResourceSet( _
CultureInfo.CurrentCulture, True, True)
MissingManifestResourceException was unhandled
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure ".resources" was correctly embedded or linked into assembly "MyProgram" at compile time, or that all the satellite assemblies required are loadable and fully signed.loadable and fully signed.
Solution (as per Hans Passant)
Copy the Namespace from the Resources.Designer.vb
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("MyNamespace.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
and place it in the code
Dim CurrentResourceManager As New ResourceManager( _
"MyNamespace.Resources", CurrentAssembly)
Dim rs As ResourceSet = CurrentResourceManager.GetResourceSet( _
CultureInfo.CurrentCulture, True, True)