Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using FileHelpers for reading csv files, and all it was ok until I switched from VS dev server to IIS, I get a "PolicyException: Required permissions cannot be acquired", I googled and found that I need to add Reflection Permission for this to work, anybody knows how ?

share|improve this question
up vote 1 down vote accepted

It sounds like you're running in partial trust. If your production environment is running in full trust, just update your dev environment to run in full trust. However, if you're trying to simulate your production environment, then here's how to change it:

Go to your framework folder/config. Find out which trust level you're on. i.e. medium, full, etc. That may be set in your site's web.config, or the framework's root web.config.

Whatever you do in dev, you'll need to do in production to. So the first step is to setup your dev like production. Then, if production is medium trust (for example), you'll need to either update the web_mediumtrust.config file or create a copy of it as a custom policy. Use the syntax in the root web.config file to see how to define it. Search for keyword 'trust'.

Add the following to your trust template: In the <SecurityClasses> section:

<SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

In the <PermissionSet class=NamedPermissionSet ..> section, add either something like this:


where Flags is a comma delimited list of specific permissions.



Make sure to get approval to have the same settings pushed to production too.

share|improve this answer
I know that this should work, but it doesn't for me, I'm on my local IIS, and I have set a Full trust level, and I still get this error – Omu Dec 5 '09 at 8:00
You shouldn't get that in full trust. My guess is that something in your .config path or code is setting the trust level. Can you include the full error message just in case there are extra hints from it? – Scott Forsyth - MVP Dec 5 '09 at 15:37
it was the Load User Profile property from DefaultAppPool AdvanceSettings, I had to set it to true. – Omu Dec 7 '09 at 7:36
no, sorry, it wasn't, it was something else, probably i was using some wrong dlls or i was referencing different dlls (instead of the same) in different assemblys – Omu Dec 7 '09 at 9:25
nope, it wasn't this either, but the answer is correct for this specific question, so I'm gonna ask another question – Omu Dec 11 '09 at 10:02

Is any of the assembly you use located on a network share? If yes than:

  • Move them to the local machine.
  • Use "Microsoft .NET Framework 2.0 Configuration" to grant full trust to local intranet.
share|improve this answer
it was the Load User Profile property from DefaultAppPool AdvanceSettings, I had to set it to true. – Omu Dec 7 '09 at 7:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.