我需要检查是否存在嵌入式资源。在 WPF 中,这相对容易,但在 WP7 中,我得到一个 MissingManifestResourceException
有效的 WPF 代码是:
public static IEnumerable<object> GetResourcePaths(Assembly assembly) {
var culture = System.Threading.Thread.CurrentThread.CurrentCulture;
//var resourceName = assembly.GetName().Name + ".g";
var assemblyName = assembly.FullName.Split(',')[0];
var resourceName = assemblyName + ".g";
var resourceManager = new ResourceManager(assemblyName, assembly);
try {
var resourceSet = resourceManager.GetResourceSet(culture, true, true);
foreach (System.Collections.DictionaryEntry resource in resourceSet) {
yield return resource.Key;
}
} finally {
resourceManager.ReleaseAllResources();
}
}
我尝试用下面的代码替换它,这导致了异常(在第 9 行)。有没有办法在 Silverlight / WP7 中做到这一点?
public static IEnumerable<object> GetResourcePaths(Assembly assembly) {
var culture = System.Threading.Thread.CurrentThread.CurrentCulture;
//var resourceName = assembly.GetName().Name + ".g";
var assemblyName = assembly.FullName.Split(',')[0];
var resourceName = assemblyName + ".g";
var resourceManager = new ResourceManager(assemblyName, assembly);
try {
var resourceSet = resourceManager.GetResourceSet(culture, true, true);
foreach (System.Collections.DictionaryEntry resource in resourceSet) {
yield return resource.Key;
}
} finally {
resourceManager.ReleaseAllResources();
}
}