Templates in Medium Trust - ServiceEditor bug?

Topics: Developer Forum, User Forum
Nov 12, 2008 at 3:28 AM
I would like to say that N2 is a brilliant piece of work, except for when it makes me want to weep.

I have been trying to run the Templates + Sample (, with and without core update) site in Medium Trust, and it appears to mostly work.  However, I have found that in edit mode:
  • Select a node in the site tree view
  • Click the "Settings" icon
  • Boom
A KeyNotFoundException is thrown from N2.Edit.Web.UI.Controls.ServiceEditor, method InitEditors.  This line:

editable.UpdateEditor(Engine, Editors[GetDictionaryKey(editable)]);

is the immediate culprit.  The larger issue is that the Editors dictionary is empty.  I have stepped through the AddEditorsRecursive method and nothing is ever added -- in N2.Definitions.EditContainerAttribute method GetContained(IPrincipal user), this.ContainedEditors is an empty Collection.  I have not debugged further to see why this is (it can be very difficult to trace down where these collections are populated), but the end result is that the Editors dictionary in ServiceEditor is empty.

Do one of the Wise Ones have an idea as to why this happens?  If I comment out the trust level="Medium" line in web.config it works without a hitch.  And don't take that weeping wisecrack to heart, N2 really is a very clever bit of code.

Nov 12, 2008 at 9:29 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Nov 12, 2008 at 9:38 PM
Thanks for finding. Medium trust is a bit hard to test. Especially since there seem to be differences between hosts and framework versions.