In VS 2010, .Net 4.0
I am trying to get the names of all the string resources in a given dll
The ultimate goal is, from a set of files, to be able to get all the resources, check which ones are Strings, and test the names to see if they have the key words I am looking for.
The main point is: I have only the dll file, nothing else.
Let say my file name is
Dim myDllFullFileName as string = "C:\Bob.dll"
First, I guess I should get the Reflection :
Dim myAssembly As New Reflection.Assembly
myAssembly=Reflection.Assembly.LoadFrom(myDllFullFileName)
Then the problems begin.
If I was simply looking for the string resources in my current project I could do that:
Dim myResourceSet As Resources.ResourceSet
myResourceSet = My.Resources.ResourceManager.GetResourceSet(Globalization.CultureInfo.CurrentCulture, True, True)
For Each Dict As DictionaryEntry In myResourceSet.OfType(Of Object)()
If TypeOf (Dict.Value) Is String Then
If Dict.Key.ToString.Contains("myOwnKeyHere") Then
'work with dict.value'
End If
End If
Next
This would work fine for my current project. And the results are exactly what I am looking for.
My problem is that I want to do it with the dll files.
I think I should be able to built a ResourSet from myAssembly. For that, I will need a ResourceManager.
To build a new ResourceManager from myAssembly, I should probably use this method:
Public Sub New(baseName As String, assembly As System.Reflection.Assembly)
And that's where I am lost: I don't manage to get the baseName from the dll file that I am using.
I also try to with
myAssembly.GetManifestResourceNames()
But it is return an empty array
If anyone has an idea, I would greatly appreciate.
Thanks.