从加载的 DLL 而不是 RESX 文件中读取 RESX 内容
我需要非常清楚这一点。我不想读取 myfile.resx 文件。我正在尝试从 myresourcenamespace.myfile.dll 读取内容。
我的希望是通过访问预加载到 DLL 中的内容来创建包含在 RESX 内容中的 KVP 的字典。我当前的解决方案过于依赖现有的文件和大量复制以确保文件位于需要的位置。此时 DLL 更加可靠。
我已经能够通过“new resourcemanager(myassembletype)”访问程序集,但我陷入了这一点。我似乎无法从记忆中读取实际内容。当我尝试从资源管理器以流的形式访问内容时,我不断遇到 MissingManifestException。
这是我的成功代码:
var myType = Type.GetType("ViewRes.StaticMessages", true);
var myResManager = new ResourceManager("StaticMessages",
System.Reflection.Assembly.GetAssembly(myType));
这是我的失败代码:
using (var fileReader = new ResXResourceSet(
myResManager.GetStream(myResManager.BaseName)))
{
//.... code read here
}
ResXResourceSet 抛出 MissingManifestException。我已经尝试了我能想到的一切。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
而不是:
尝试这样:
现在你可以循环:
Instead of:
Try like this:
now you can loop: