title: WebAPI OData 5.0 Beta - Accessing GlobalConfiguration throws Security Error
body: <p>I recently installed the pre-release version of the WebApi OData 5.0 framework to play with the new $expand support. Everything built okay, but I get a strange exception on App_Start.</p>
  
  <pre><code>Attempt by security transparent method
  'System.Web.Http.GlobalConfiguration.get_Configuration()' 
  to access security critical type 'System.Web.Http.HttpConfiguration' failed.
  </code></pre>
  
  <p>Source Error:</p>
  
  <pre><code>Line 12:    protected void Application_Start()
  Line 13:    {
  Line 14:        WebApiConfig.Register(GlobalConfiguration.Configuration); // &lt;--
  Line 15:    }
  </code></pre>
  
  <p>Stack Trace:</p>
  
  <pre><code>[TypeAccessException: Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access 
  security critical type 'System.Web.Http.HttpConfiguration' failed.]
     System.Web.Http.GlobalConfiguration.get_Configuration() +0
     API.WebApiApplication.Application_Start() in Global.asax.cs:14
  
  [HttpException (0x80004005): Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access 
  security critical type 'System.Web.Http.HttpConfiguration' failed.]
     System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12863325
     System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
     System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
     System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
     System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
  
  [HttpException (0x80004005): Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access 
  security critical type 'System.Web.Http.HttpConfiguration' failed.]
     System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12880068
     System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
     System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12721257
  </code></pre>
  
  <p>Google reveals very little.</p>