我已經在ASP.net MVC4,框架版本4.5中開發了一個小型webapp。在使用Visual Studio 2015進行調試時,這一切都像一個魅力。但是我沒有Windows服務器,而是Linux(Ubuntu 14.04 VPS),我希望在那裏部署。mod_mono asp MVC4錯誤:System.Security.SecurityException - 無法模擬令牌
我有最新的mono和mod_mono與apache2運行。它似乎執行,因爲它應該,但我得到一些錯誤。
我解決了其中的第一個問題,加入<customError mode="off">
也看到了錯誤,然後添加了一個mono/register
文件夾。
但我現在這個錯誤難倒:
System.Security.SecurityException
Couldn't impersonate token.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
at System.Security.Principal.WindowsImpersonationContext..ctor (IntPtr token) <0x41ef9dd0 + 0x0006f> in <filename unknown>:0
at System.Security.Principal.WindowsIdentity.Impersonate (IntPtr userToken) <0x41ef9d50 + 0x0003c> in <filename unknown>:0
at System.CodeDom.Compiler.Executor.ExecWaitWithCapture (IntPtr userToken, System.String cmd, System.String currentDir, System.CodeDom.Compiler.TempFileCollection tempFiles, System.String& outputName, System.String& errorName) <0x41ef9c90 + 0x00038> in <filename unknown>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.Compile (System.CodeDom.Compiler.CompilerParameters options, System.String compilerFullPath, System.String arguments, System.String& outputFile, System.Int32& nativeReturnValue) <0x41ef9a10 + 0x0010b> in <filename unknown>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) <0x41ef5c40 + 0x005fb> in <filename unknown>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) <0x41ef5aa0 + 0x000c7> in <filename unknown>:0
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) <0x41ef58f0 + 0x0004d> in <filename unknown>:0
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) <0x41ee0a70 + 0x00991> in <filename unknown>:0
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) <0x41ee0a30 + 0x00023> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) <0x41ed6b10 + 0x009b7> in <filename unknown>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) <0x41eac440 + 0x00523> in <filename unknown>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) <0x41eabbc0 + 0x0011b> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) <0x41eaaa70 + 0x00093> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) <0x41eaa690 + 0x00017> in <filename unknown>:0
at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) <0x41e9c4a0 + 0x0041b> in <filename unknown>:0
我一直無法修復該錯誤。我曾嘗試以下步驟:
- 公佈的項目到本地文件夾並將其複製到我的Linux
- 服務器採取了整個項目,並添加到Linux服務器建造
- 整個項目的Linux上xbuild
這都給出了相同的運行時錯誤。
我用特拉維斯CI來檢查我的代碼,並將其傳遞,具有以下配置:
language: CSharp
solution: BannedFromHighsec.sln
script:
- nuget restore BannedFromHighsec.sln
- xbuild /p:Configuration=Release /target:BannedFromHighsec BannedFromHighsec.sln /p:TargetFrameworkVersion="v4.5" /p:DebugSymbols=False
引擎收錄的特拉維斯CI日誌:http://pastebin.com/5s6p97i3
所以我還挺想朝這是我的代碼,還有的有什麼問題。但我不確定它是什麼,因爲它是一個簡單的應用程序。使用SQlite和從API和第二個數據庫提取數據的操作非常基本。我沒有使用登錄或任何東西。
我希望有人可以幫助我,我開始得到一個asp.net MVC的句柄,並且想知道如何在Linux上實際部署它,如果可能的話。 :)
如果您需要任何其他信息,配置,源代碼讓我知道,我會很樂意給它。只是不知道該錯誤代碼需要什麼。
OMFG。我愛你!!!! 我花了很多時間在這個問題上,有點放棄了。感謝這個工程! :D 我不得不修復一些其他錯誤,但主要是由於Sqlite需要定製構建.dll。並不得不刪除「Microsoft.Ai.Web.dll」 – Frederik
令人難以置信,也花了很長時間在這些錯誤,並遵循你的解決方案,現在它的工作原理! – Sierramike
這些行配置給定編譯器[1]應如何處理每個擴展。所以我猜Mono編譯器無法匹配引發'SecurityException'的'type'和'publickey'屬性。問題是......哪些是單聲道編譯器的類型?儘管你應該可以將pubkey屬性留空[2]。 [1] https://msdn.microsoft.com/en-us/library/y9x69bzw(v=vs.110).aspx [2] https://msdn.microsoft.com/en-us/library/yfsftwz6( v = vs.110).aspx – Sdlion