不支持 Xamarin 反射 Assembly.LoadFile [英] Xamarin Reflection Assembly.LoadFile not supported
问题描述
我正在寻找修复此错误的方法:
i´m looking for an fixing of this error:
System.NotSupportedException:AppX 不支持 Assembly.LoadFile."
System.NotSupportedException: "Assembly.LoadFile is not supported in AppX."
我有一个 Xamarin 项目,我正在尝试创建一个我的类型的实例.总而言之,它看起来像这样:
I´ve got an Xamarin-Project and i ´m trying to create an instance of a type of mine. all in all it looks like this:
var assembly = Assembly.LoadFile("MicroChatsTest.dll");
var type = typeof(IUpdate);
var mytypes = assembly.GetTypes().Where(p => type.IsAssignableFrom(p)).FirstOrDefault();
if (mytypes == null) throw new Exception("E1234");
var whatever = Activator.CreateInstance(mytypes);
错误出现在第一行,因为 AppX/Xmarin 不支持 Assembly.LoadFile,是否有可能解决这个问题?非常感谢.
the error comes in the first line, because AppX/Xmarin doesn´t support the Assembly.LoadFile, is there any possibillity to fix this? thanks a lot.
推荐答案
很遗憾,您无法在 Xamarin 中加载非 AOT 编译的程序集:https://forums.xamarin.com/discussion/2294/装配加载是可能的
Unfortunately, you cannot load non-AOT compiled assemblies in Xamarin: https://forums.xamarin.com/discussion/2294/assembly-load-is-it-possible
这篇关于不支持 Xamarin 反射 Assembly.LoadFile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!