4

I Have around say 6 dll's ( No source code ). They do not contain any Logic but just a .resx file that contains a string table.

Is there a way where I can extract the Id's and values from the string table from each of these dll's and Export it to a text file?

1 Answer 1

6

Knowing the assembly name and the resource file, you can load it using reflection.

// Resources dll
var assembly = Assembly.LoadFrom("ResourcesLib.DLL");

// Resource file.. namespace.ClassName
var rm = new ResourceManager("ResourcesLib.Messages", assembly);

// Now you can get the values
var x = rm.GetString("Hi");

To list all Keys and Values you can use the ResourceSet

var assembly = Assembly.LoadFrom("ResourcesLib.DLL");
var rm = new ResourceManager("ResourcesLib.Messages", assembly);

var rs = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);

foreach (DictionaryEntry r in rs)
{
    var key = r.Key.ToString();
    var val = r.Value.ToString();
}

If you don't have access to the resources lib, you can see what are the namespaces, classes, and everything else through Reflector as mentioned by Leo.

Sign up to request clarification or add additional context in comments.

4 Comments

yeah, doesn`t need to be dynamic hehehe, but one day i will found something that it fits hehehe, by the way.... this solution should works
Yes, It does List the resources in rm, But I do not know the Ids in the string table. So How do i use it in GetString?
I need to list the Ids and the value !
@Maneesh: Updated to list all resources.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.