The application attempted to perform an operation not allowed by the security policy

This worked for me. in web.config add

<system.web>
   <trust level="Full" />
</system.web>

This is an old question, but I experienced this exact issue recently and as the problem existed on the local machine and not on a remote one like most of the rest of the information pulled up with this particular error, none of those solutions helped so I'm going to put my solution here.

My issue was that I was using a networked workstation and trying to run a solution that was stored on a network drive. For some reason, my local machine did not trust that particular drive and it would not accept any of the attempts to raise the trust level of the application.

Once I realized the issue was the drive itself, I simply moved the entire solution over to another one and it solved the problem for me. I imagine that a talk with the Network Admin about their permissions could likely helped to correct the error also, but just switching the solution to a local drive fixed the issue that I was having and might work for others.

Tags:

Asp.Net