Noorul
Noorul

Reputation: 923

GetReferencedAssemblies throws "Operation is not supported on this platform"

I am working on .NET standard library and I am trying to get all referenced assemblies from entry assembly.

Here is my code

AssemblyName[] allAssemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies();

This code is working perfectly in debug mode, and I am able to get all referenced assemblies from the entry assembly (UWP app).

But in release mode GetReferencedAssemblies() throws System.PlatformNotSupportedException: 'Operation is not supported on this platform.' exception , and I am not able to get the referenced assemblies in a uwp app.

Upvotes: 0

Views: 277

Answers (1)

magicandre1981
magicandre1981

Reputation: 28836

Release Mode uses .NET Native, which compiles managed code into native code:

.NET Native is a precompilation technology for building and deploying Windows apps that is included with Visual Studio 2015 and later versions. It automatically compiles the release version of apps that are written in managed code (C# or Visual Basic) and that target the .NET Framework and Windows 10 to native code.

and here it is not implemented for CoreRT.

GetReferencedAssemblies is not implemented. We could implement it, but for situations like this users often have a need to actually reference assemblies that are otherwise unreferenced anyway (plugins, or platform light up), so this API is pretty deep in our backlog right now.

Upvotes: 2

Related Questions