在 UWP 中使用 System.Reflection.Emit 动态创建一个类 [英] Create a class dynamically using System.Reflection.Emit in UWP

查看:26
本文介绍了在 UWP 中使用 System.Reflection.Emit 动态创建一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 UWP 中使用 System.Reflection.Emit 动态创建一个类.在 UWP AppDomain.CurrentDomain.DefineDynamicAssembly 中丢失.请提出任何解决方案.

Create a class dynamically using System.Reflection.Emit in UWP. in UWP AppDomain.CurrentDomain.DefineDynamicAssembly is missing. Please suggest any solution.

推荐答案

您需要为 System.Reflection.Emit 在您的项目中.他们一直在将 API 的各个部分分解成单独的包.

You need to include the Nuget package for System.Reflection.Emit in your project. They've been breaking out parts of the API into separate packages.

然后就可以使用 AssemblyBuilder.DefineDynamicAssembly 方法在 UWP 项目的内存中创建程序集.

Then you can use the AssemblyBuilder.DefineDynamicAssembly method to create an assembly in memory in a UWP project.

但这不适用于 .NET Native Toolchain,这意味着您可能无法提交到商店:

But this won't work with the .NET Native Toolchain, which means you probably won't be able to submit to the store:

https://blogs.windows.com/buildingapps/2015/08/20/net-native-what-it-means-for-universal-windows-platform-uwp-developers/#8t4LmYa5JGBQXsRk.97

https://docs.microsoft.com/en-us/windows/uwp/packaging/packaging-uwp-apps

这篇关于在 UWP 中使用 System.Reflection.Emit 动态创建一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆