11

AppHost で Init() を呼び出すと、上記のエラーが発生します。

これは、入門チュートリアルに従って、単純な HelloWorld サービスを備えたクリーンな asp.net v 4.5 の空の Web アプリケーションです。

具体的には、次のものがインストールされている ServiceStack の古いバージョンを使用しています。

Install-Package ServiceStack -Version 3.9.71

次への参照をインストールします。

ServiceStack.dll 3.9.70.0
ServiceStack.Common.dll 3.9.9.0
ServiceStack.Interfaces.dll 3.9.9.0
ServiceStack.OrmLite.dll 3.9.14.0
ServiceStack.OrmLite.SqlServer.dll 1.0.0.0
ServiceStack.Redis.dll 3.9.11.0
ServiceStack.ServiceInterface.dll 3.9.70.0
ServiceStack.Text.dll 4.0.11.0

そして、私が得るエラーは次のとおりです。

[TypeLoadException: Could not load type 'ServiceStack.ServiceHost.IService' from assembly 'ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, PublicKeyToken=null'.]
   Falck.WebAPI.AppHost..ctor() in c:\inetpub\wwwroot\WebAPI\Falck.WebAPI\Global.asax.cs:17
   Falck.WebAPI.Global.Application_Start(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebAPI\Falck.WebAPI\Global.asax.cs:29

[HttpException (0x80004005): Could not load type 'ServiceStack.ServiceHost.IService' from assembly 'ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, PublicKeyToken=null'.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9865825
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Could not load type 'ServiceStack.ServiceHost.IService' from assembly 'ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, PublicKeyToken=null'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9880168
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

タイプをロードできないと言われていますが、その理由はわかりませんか?

以下は、nuget からの出力です。

Package Manager Console Host Version 2.8.50126.400

Type 'get-help NuGet' to see all available NuGet commands.

PM> Install-Package ServiceStack -Version 3.9.71
Attempting to resolve dependency 'ServiceStack.Common (≥ 3.0 && < 4.0)'.
Attempting to resolve dependency 'ServiceStack.Text'.
Attempting to resolve dependency 'ServiceStack.Redis (≥ 3.0 && < 4.0)'.
Attempting to resolve dependency 'ServiceStack.OrmLite.SqlServer (≥ 3.0 && < 4.0)'.
Installing 'ServiceStack.Text 4.0.11'.
You are downloading ServiceStack.Text from Service Stack, the license agreement to which is available at https://servicestack.net/terms. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'ServiceStack.Text 4.0.11'.
Installing 'ServiceStack.Common 3.9.11'.
Successfully installed 'ServiceStack.Common 3.9.11'.
Installing 'ServiceStack.Redis 3.9.11'.
Successfully installed 'ServiceStack.Redis 3.9.11'.
Installing 'ServiceStack.OrmLite.SqlServer 3.9.14'.
Successfully installed 'ServiceStack.OrmLite.SqlServer 3.9.14'.
Installing 'ServiceStack 3.9.71'.
Successfully installed 'ServiceStack 3.9.71'.
Adding 'ServiceStack.Text 4.0.11' to Falck.WebAPI.
Successfully added 'ServiceStack.Text 4.0.11' to Falck.WebAPI.
Adding 'ServiceStack.Common 3.9.11' to Falck.WebAPI.
Successfully added 'ServiceStack.Common 3.9.11' to Falck.WebAPI.
Adding 'ServiceStack.Redis 3.9.11' to Falck.WebAPI.
Successfully added 'ServiceStack.Redis 3.9.11' to Falck.WebAPI.
Adding 'ServiceStack.OrmLite.SqlServer 3.9.14' to Falck.WebAPI.
Successfully added 'ServiceStack.OrmLite.SqlServer 3.9.14' to Falck.WebAPI.
Adding 'ServiceStack 3.9.71' to Falck.WebAPI.
Successfully added 'ServiceStack 3.9.71' to Falck.WebAPI.
4

4 に答える 4

1

NuGet パッケージのインストールは非常に間違っています。NuGet を実行して正しいパッケージとバージョンを取得したので、これは奇妙に思えます。

実行Install-Package ServiceStack -Version 3.9.71すると、次のバージョンの dll を含む次のパッケージがインストールされます。

  • サービススタック 3.9.71

    ServiceStack.dll 3.9.71
    ServiceStack.ServiceInterface.dll 3.9.71

  • ServiceStack.Common 3.9.71

    ServiceStack.Common.dll 3.9.71
    ServiceStack.Interfaces.dll 1.0.0

  • ServiceStack.Redis 3.9.71

    ServiceStack.Redis.dll 3.9.71

  • ServiceStack.OrmLite.SqlServer 3.9.71

    ServiceStack.OrmLite.dll 3.9.71
    ServiceStack.OrmLite.SqlServer.dll 3.9.71

  • ServiceStack.Text 3.9.71

    ServiceStack.Text.dll 3.9.71

提案:

  1. プロジェクトからすべての参照を削除します。
  2. を取り外しますpackages.config
  3. プロジェクトのターゲットが .NET 4.5 であることを確認します。
  4. プロジェクトをクリーンアップします。
  5. 次に、NuGet コマンドを再実行します。
于 2014-02-25T16:18:41.443 に答える