title: ASP.NET An attribute argument must be a constant expression
body: <p>In my ASP.net project i'm using the <a href="http://msdn.microsoft.com/en-us/library/wce3kxhd.ASPX" rel="nofollow" title="Authrization">Authorization</a> to only allow a user that is member of the given group. To make this a bit more easy for a future owner of the website i'm making the role adjustable. I try to do the following: </p>
  
  <pre><code>SettingsController set = new SettingsController();
  
  private string Roles()
  {
      return set.settingsGroup;
  }
  
  [Authorize(Roles = Roles())]
  ....
  </code></pre>
  
  <p>Now <code>set.settingsGroup</code> returns a string that is parsed from a XML file.
  But when i try to set it on the Authorize i get the error </p>
  
  <blockquote>
    <p>An object reference is required for the non-static field, method or
    property</p>
  </blockquote>
  
  <p>I don't fully understand the error, so i'm asking you guys and girls for help.</p>
  
  <p>So don't be shy.</p>
  
  <p><em><strong></em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>_</strong><em>UPDATE</em><strong><em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__</strong></p>
  
  <p>So with some help i now understand what i have to do.
  And as a solution i made de function roles static, and created a new instance of SettingsController.</p>
  
  <pre><code>private static string Roles()
  {
      SettingsController set = new SettingsController();
      set.parseXML();
      return set.settingsGroup;
  }
  </code></pre>
  
  <p>But now when i call Roles() in the Authorize is get an new error that is even longer:</p>
  
  <blockquote>
    <p>An attribute argument must be a constant expression, typeof expression
    or array creation expression of an attribute parameter type</p>
  </blockquote>
  
  <p>So if i try to read this error is seems that a give an attribute or parameter with the Roles() function. And that is not of the correct type. But i don't give any parameters so?</p>