我有代码可以读取 XAP 并反射(reflect)其中的 DLL。这在 Silverlight 中有效,但在 Windows Phone 7 中无效。有没有办法做到这一点,因为 AssemblyPart.Load 不在 Windows Phone DLL 中。
谢谢,代码是:
var client = new System.Net.WebClient();
client.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
{
StreamResourceInfo resourceInfoDLL = Application.GetResourceStream(
new StreamResourceInfo(e.Result, null),
new Uri("Some.DLL", UriKind.Relative));
AssemblyPart assemblyPart = new AssemblyPart();
Assembly assembly = assemblyPart.Load(resourceInfoDLL.Stream);
.
.
};
client.OpenReadAsync(new Uri("Some.xap", UriKind.Relative));
最佳答案
不,Windows Phone 7 不支持这种反射。您只能反射(reflect)公共(public)类型或内部类型(即来自同一程序集)。 Microsoft 不希望人们侵入未通过公共(public) API 直接公开的功能。
而且...为什么要从 XAP 内部读取 XAP?这对我来说似乎没有意义。
关于.net - 在 Windows Phone API 中反射 DLL (SIlverlight),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6824589/