1

It seems to be a deliberate security of Windows 10 Store apps that assemblies not be allowed to be loaded at runtime. I think that this feature is massive overkill and stops UWP development dead in its tracks. However, if it is a rock solid design decision by Microsoft, there is nothing we can do to argue with it.

Instead, I'd like to ask the question, assuming that you were not deploying your UWP app to the store, would it still be impossible to load an assembly dynamically? If it's possible, how?

Please see this feature request: https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/18145291-dynamically-load-assembly

Christian Findlay
  • 6,770
  • 5
  • 51
  • 103

2 Answers2

1

Regardless of what environment you deploy your UWP application to, the UWP API will be the same. Choosing to deploy your app internally instead of to the Windows Store will not enable non-supported API features, eg. Assembly.Load().

ryancdotnet
  • 2,015
  • 16
  • 33
  • I'm doing my best to keep a lid on my feelings about this limitation, but this limitation is based on store policy, not on the capability of the runtime. Why doesn't Microsoft just expose the method in the runtime environment, but make it throw an exception if running as an app store app? – Christian Findlay Feb 15 '17 at 00:52
  • But adding extra assemblies wouldn't add extra capabilities to the app. Just because an assembly is loaded after startup doesn't mean that the app gets an extra capabilities. Saying that is just a red herring. UWP is a sandboxed runtime. Ultimately it still gets to choose which APIS can be run at which times. – Christian Findlay Feb 15 '17 at 00:55
  • Beside all this, I'm talking about an enterprise level app that will not be available to the general public. Microsoft is not responsible for the quality of our software - we are! It's obviously a completely different case when the app is freely available to anyone in the app store. – Christian Findlay Feb 15 '17 at 00:59
  • I've changed my answer to remove my personal thoughts and only supply a direct answer to your direct question. I feel this is more appropriate for SO. Unless officially announced, all we can do is guess "why this" or "why that". Let's work with what we have today, and if that changes, go from there. SO is not a forum to debate Microsoft's decisions, and I'm sorry if I encouraged such. – ryancdotnet Feb 15 '17 at 21:00
0

It seems as though the answer to this question is no.

The game has changed in UWP. UWP is a platform which is geared toward getting apps in to the store. It's a stripped down platform and doesn't appear to allow you to load assemblies at runtime. This was possible in .NET.

However, there does seem to be a way to run UWP style apps on top of the .NET runtime using the Desktop Bridge. I'm not really that familiar with it, but you can read more here as a starting my point. My guess is that if you want to load assemblies dynamically, the best approach would be to use this: https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-root

Christian Findlay
  • 6,770
  • 5
  • 51
  • 103
  • With the Fall Creators Update, you may want to look into Optional Application Packages, which allows it in a form - though they have to specifically ne built to target your application. https://learn.microsoft.com/en-us/windows/uwp/packaging/optional-packages – Johnny Westlake Oct 20 '17 at 10:02