SINU S
SINU S

Reputation: 59

Create a class dynamically using System.Reflection.Emit in UWP

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

Answers (2)

Michael Hawker - MSFT
Michael Hawker - MSFT

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://blogs.windows.com/buildingapps/2015/08/20/net-native-what-it-means-for-universal-windows-platform-uwp-developers/#8t4LmYa5JGBQXsRk.97

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

Upvotes: 3

snickler
snickler

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

Related Questions