locked
Reading RESX Content from loaded DLL and NOT the RESX file RRS feed

  • Question

  • User645573348 posted

    I need to be really clear on this. I am not trying to read the myfile.resx file. I am trying to read the content from the myresourcenamespace.myfile.dll.

    My hopes is to create a dictionary of my KVPs contained within the RESX content, by accessing that which is preloaded into the DLLs. My current solution depends too much on the files exisiting and a bunch of copying to insure that files are where they need to be. The DLLs are more reliable at this point.

    I have been able to gain access to the assembly via "new resourcemanager(myassemblytype)", but I am stuck at this point. I cannot seem to read the actual content from memory. I continually run up against MissingManifestException when I try and access the content as a stream from the resource manager.

    Here is my successful code:

    var myType = Type.GetType("ViewRes.StaticMessages", true);
    var myResManager = new ResourceManager("StaticMessages", System.Reflection.Assembly.GetAssembly(myType));

    Here is my failure code:

    using (var fileReader = new ResXResourceSet(myResManager.GetStream(myResManager.BaseName)))
    {
    //.... code read here
    }

    The ResXResourceSet throws the MissingManifestException. I have tried everything I can think of.

    Wednesday, July 6, 2011 4:19 PM

Answers

  • User-276842610 posted

    hi,

    Please try to use as follows and check if it works.

    var myType = Type.GetType("ViewRes.StaticMessages", true);
    var myResManager = new ResourceManager("StaticMessages", System.Reflection.Assembly.GetExecutingAssembly(myType));

    instead of

    var myType = Type.GetType("ViewRes.StaticMessages", true);
    var myResManager = new ResourceManager("StaticMessages", System.Reflection.Assembly.GetAssembly(myType));

    thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 12, 2011 6:13 AM