Is it possible to run a stand-alone WPF application (non XBAP) in Partial Trust?

634 views Asked by At

I thought if I do not use anything beyond simple graphic in a window, I would be able to run a stand-alone WPF application in Partial Trust (at least on Intranet). But unfortunately, even simplest Hello World application fails to load the main window and crashes if run with partial trust.

Anybody can shed some light on why this happens and if it even theoretically possible?

P.S. Simplest console application can run in partial trust in Intranet Zone, and Winforms can run both in Intranet and Internet (though it displays a security warning when running in Intranet Zone)

1

There are 1 answers

0
Sergey Aldoukhov On BEST ANSWER

After playing with it some more, I found my problem was that I tried my app to run under debugger. Without debugging, simple WPF app can run fine in both internet and intranet zones.

When debugging, WPF application requires additional permissions to zone's default set. These permissions are:

  • Allow calls to unmanaged assemblies (Security permission) in both Intranet and Internet. Still not sure why this is different from WinForms and what unmanaged assembly it needs in debug mode.
  • All windows and events (UI permission) in Internet zone.

If these two permissions are set, you can debug your WPF application in Partial Trust. Just do not forget to reset the permissions when compiling a release!