在 UWP 中使用 System.Reflection.Emit 动态创建一个类 [英] Create a class dynamically using System.Reflection.Emit in UWP
问题描述
在 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://docs.microsoft.com/en-us/windows/uwp/packaging/packaging-uwp-apps
这篇关于在 UWP 中使用 System.Reflection.Emit 动态创建一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!