1

VSO から Windows Azure にアプリケーションを発行することができました。問題は、私のアプリケーションがこのエラーで Azure で起動できないことです (ローカルでは完全に動作します)。

System.TypeInitializationException: The type initializer for 'Microsoft.AspNetCore.Server.Kestrel.Networking.PlatformApis' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.AspNetCore.Server.Kestrel.Networking.PlatformApis..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Networking.PlatformApis.get_IsWindows()
   at Microsoft.AspNetCore.Server.Kestrel.Networking.Libuv..ctor()
   at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at MyApp.Web.Startup.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.<ExecuteMain>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Microsoft.AspNetCore.Server.Kestrel.Networking.PlatformApis..cctor()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

依存関係を手動で追加しようとしましたが、問題は解決しませんでした:

"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-rc2-23826"

ここに私の設定があります

グローバル.json:

{
  "projects": [ "src", "test", "lib" ],
  "sdk": {
    "version": "1.0.0-rc2-20221",
    "runtime": "clr",
    "architecture": "x86"
  }
}

プロジェクト.json

  "compilationOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "Jil": "2.13.0",
    "JWT": "1.3.4",
    "Microsoft.AspNetCore.Authentication": "1.0.0-rc2-20270",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-20270",
    "Microsoft.AspNetCore.Hosting": "1.0.0-rc2-20270",
    "Microsoft.AspNetCore.Http.Abstractions": "1.0.0-rc2-20270",
    "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-rc2-20270",
    "Microsoft.AspNetCore.Mvc.Core": "1.0.0-rc2-20270",
    "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0-rc2-20270",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-20270",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-20270",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-20270",
    "Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-20270",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-20270",
    "Microsoft.Extensions.PlatformAbstractions.Dnx": "1.0.0-rc2-20221",
    "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-rc2-23826"
  },
  "frameworks": {
    "net46": { }
  }
4

1 に答える 1

2

IIS でローカルにテストする

Azure は内部で IIS を使用しています。アプリが IIS で機能する場合、通常は Azure Web アプリで機能します。公式ドキュメントには、IIS に公開するための明確な指示があります。IIS で動作したら、同じものを Azure にデプロイします。

RC2 Azure パブリッシュ ウォークスルー

これが私にとってうまくいく正確な公開手順です。あなたの質問から project.json を使用するサンプルを作成し、そのサンプルを GitHub にプッシュしました

サンプルを複製します。

C:\> git clone https://github.com/bigfont/StackOverflow.git
C:\> cd .\StackOverflow\RuntimeInfo

次に、プロジェクトを公開します。

C:\StackOverflow\RuntimeInfo> dnvm use 1.0.0-rc2-20221 -runtime clr
C:\StackOverflow\RuntimeInfo> dotnet restore
C:\StackOverflow\RuntimeInfo> dotnet publish -c Release -o ./approot

これらのコマンドは、RC2 ランタイムを対象とし、NuGet パッケージを復元し、リリース構成を approot ディレクトリに公開します。結果は次のとおりです。

C:\StackOverflow\RuntimeInfo> dir
approot            
bin                
obj                            
Program.cs         
project.json       
project.lock.json     
wwwroot

ここで、FTP を使用して、approotおよびwwwrootディレクトリを Azure のsiteディレクトリに発行します。

./site
    approot
    wwwroot

これは Azure での結果です。

Azure での System.Runtime.InteropServices の使用

最後の注意

「小川を渡る」ことに注意してください。アプリの project.json/global.json ファイルには、1.0.0-rc2-20221 と 1.0.0-rc2-20270 の 2 つのリリース バージョンがあります。どちらかを選んだ方が良さそうです。

于 2016-03-21T00:02:22.777 に答える