【问题标题】:Xamarin Reflection Assembly.LoadFile not supported不支持 Xamarin 反射 Assembly.LoadFile
【发布时间】:2019-01-09 09:25:35
【问题描述】:

我正在寻找解决此错误的方法:

System.NotSupportedException:“AppX 不支持 Assembly.LoadFile。”

我有一个 Xamarin 项目,我正在尝试创建一个我的类型的实例。总而言之,它看起来像这样:

        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,是否有可能解决此问题?非常感谢。

【问题讨论】:

  • 只有在 Android 上你才能做到这一点,Apple 禁止在运行时加载/JIT'd 的非应用签名代码。 UWP 实施了类似的限制。
  • 给这个程序集添加一个常规引用​​怎么样?
  • “常规引用”是什么意思?
  • 只是使用 Visual Studio 的参考。右键单击项目,添加引用。

标签: c# xamarin reflection .net-assembly


【解决方案1】:

很遗憾,您无法在 Xamarin 中加载非 AOT 编译的程序集: https://forums.xamarin.com/discussion/2294/assembly-load-is-it-possible

【讨论】:

  • @SKirchner 这个错误发生在什么操作系统上? iOS 还是安卓?
  • 现在,我正在调试到 UWP
  • @SKirchner 请参考我链接到的主题,他们在那里讨论潜在的解决方法。
猜你喜欢
  • 1970-01-01
  • 2012-09-26
  • 2017-09-15
  • 2022-06-14
  • 2014-07-23
  • 2019-09-19
  • 2022-01-23
  • 1970-01-01
  • 2015-12-30
相关资源
最近更新 更多