13

私は最近、WebApi OData 5.0 フレームワークのプレリリース バージョンをインストールして、新しい $expand サポートを試してみました。すべてが正常にビルドされましたが、App_Start で奇妙な例外が発生します。

Attempt by security transparent method
'System.Web.Http.GlobalConfiguration.get_Configuration()' 
to access security critical type 'System.Web.Http.HttpConfiguration' failed.

ソース エラー:

Line 12:    protected void Application_Start()
Line 13:    {
Line 14:        WebApiConfig.Register(GlobalConfiguration.Configuration); // <--
Line 15:    }

スタックトレース:

[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

グーグルはほとんど明らかにしていません。

4

4 に答える 4

12

私はこの同じエラーを抱えていました。Ravi の回答を少し調整したところ、WebApi パッケージを更新してから WebApi.OData 5.0.0-rc1 パッケージを更新/インストールすると、十分に機能することがわかりました。パッケージマネージャーでこれらを実行しました:

Update-Package Microsoft.AspNet.WebApi -Pre
Install-Package Microsoft.AspNet.WebApi.OData -Version 5.0.0

WebApi.OData パッケージのプレリリース バージョンには、Nuget が依存関係として検査できない新しいバージョンの WebApi パッケージとの依存関係があると推測しています。繰り返しになりますが、私は技術的には WebApi OData の初心者であり、パッケージについてはまだあまり知りませんが、$expand および $select 機能を使用してプロジェクトを実行でき、GlobalConfiguration エラーは発生しません。:)

于 2013-09-10T07:53:53.993 に答える