Exceptions when EPiServer site with Page Type Builder starts
It’s common (at least for me) to run into security exceptions when adding Page Type Builder to an EPiServer project.
Exception messages usually include “EPiServer - ReflectionTypeLoadException: Unable to load one or more of the requested types” or "That assembly does not allow partially trusted callers".
Nine times out of then (or maybe 10 out of 10) this is because the Page Type Builder assemblies aren’t fully trusted. This in turn is because the assemblies were downloaded off the internet and thus became partially blocked.
Unblock Page Type Builder assemblies
To fix the problem, right-click each assembly and check the Security option at the bottom of the General tab. If you see an Unblock button – click it! :)
Repeat for all Page Type Builder assemblies
Repeat this step for all assemblies required by Page Type Builder and those nasty System.Web.AspNetHostingPermission exceptions should go away!
UPDATE: If you’ve downloaded a set of assemblies in a ZIP file you should unblock the entire zip file before unzipping it. Otherwise you’ll have to do it for each assembly file individually.