问题描述
我有一个Web服务,可为我提供一个生成的.resx(仅XML),然后将其转换为二进制文件 .resources
.我目前正在使用 al.exe
生成带有该程序集的文件.这是我的论点:
I have a web service which supplies me with a generated .resx (XML only) which I then convert to binary a .resources
file. I am currently generating an assembly file with that using al.exe
. Here are my arguments:
/t:lib /c:{culture} /embed:"{.resource input}" /out:"{.dll output}"
通过 Assembly.LoadFrom(file)
加载此程序集可以正常工作,但是我认为我的程序集无法正确生成.它没有类型,名称空间或要调用的方法,因此显然没有 ResourceManager
.
Loading this assembly in via Assembly.LoadFrom(file)
works fine, but I believe that my assembly is not properly generated. It has no type, namespace, or methods to invoke and therefor no ResourceManager
apparently.
本质上,我只是想知道是否有可能生成,加载和利用在编译时没有我的项目知道的类或名称空间的资源.谢谢.
Essentially I am just wondering if it is at all possible to generate, load, and utilize resources that have no class or namespace which my project knows about at compile time. Thanks.
推荐答案
您的程序集是附属程序集.来自 MSDN :
Your assembly is a satellite assembly. From MSDN:
如果您想访问该程序集的资源-类似的代码应该可以工作:
If you want to access the resources of this assembly - similar code should work:
ResourceManager rm = new ResourceManager(
"ResourceTest.Properties.Resources",
Assembly.LoadAssembly(file));
MessageBox.Show(rm.GetString("helloWorldString"));
此外,MSDN上的文章:演练:从附属程序集中加载资源显示了另一种从附属程序集中加载资源字符串的方法.
Also, the article from MSDN: Walkthrough: Loading Resources from a Satellite Assembly shows an alternative way of how to load a resource string from a satellite assembly.
这篇关于加载“松散"的邮件运行时本地化的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!