Reputation: 59
Create a class dynamically using System.Reflection.Emit in UWP. in UWP AppDomain.CurrentDomain.DefineDynamicAssembly is missing. Please suggest any solution.
Upvotes: 5
Views: 1126
Reputation: 1580
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.
Then you can use the AssemblyBuilder.DefineDynamicAssembly
method to create an assembly in memory in a UWP project.
But this won't work with the .NET Native Toolchain, which means you probably won't be able to submit to the store:
https://learn.microsoft.com/en-us/windows/uwp/packaging/packaging-uwp-apps
Upvotes: 3
Reputation: 94
From what I've read through the Windows 10 API and from trying to code this myself, AppDomain is not available at all. Although the TypeBuilder and AssemblyBuilder API show that it's supported in Windows 10, this seems to be false. It doesn't actually exist within the UWP version of System.Reflection and System.Reflection.Emit. Neither does AppDomain.
Windows 10 Supported Reflection Types
Upvotes: 1