【发布时间】:2016-05-22 22:13:11
【问题描述】:
我在 ASP.net MVC4 框架版本 4.5 中开发了一个小型 webapp。在使用 Visual Studio 2015 进行调试时,这一切都像一个魅力。但是我没有 Windows 服务器,而是一个 Linux(Ubuntu 14.04 VPS),我希望在那里部署。
我有最新的单声道和 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 的整个项目
这都给出了相同的运行时错误。
我使用 Travis 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
Travis CI 日志的Pastebin:http://pastebin.com/5s6p97i3
所以我有点想这是我的代码有问题。但我不确定它是什么,因为它是一个简单的应用程序。几乎所有基本的 CRUD 操作都使用 SQlite 并从 API 和第二个数据库中提取数据。我没有使用登录名或任何东西。
我希望有人可以帮助我,我开始掌握 asp.net MVC,如果可能的话,想知道如何将它实际部署在 linux 上。 :)
如果您需要任何其他信息、配置、源代码,请告诉我,我很乐意提供。只是不确定该错误代码需要什么。
【问题讨论】:
标签: asp.net linux asp.net-mvc-4 mono mod-mono