我在ASP.net MVC4,框架版本4.5中开发了一个小webapp。 在使用Visual Studio 2015进行debugging时,这一切都像一个魅力。但是,我没有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
我一直无法解决这个错误。 我已经尝试了以下步骤:
这都给出了相同的运行时错误。
我已经使用Travis CI检查我的代码,并通过以下configuration:
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
所以我有点思考这是我的代码有什么问题。 但是我不确定这是一个简单的应用程序。 使用SQlite进行基本的CRUD操作,并从API和第二个数据库中提取数据。 我没有使用login或任何东西。
我希望有人可以帮助我,我开始得到一个处理asp.net MVC,并想知道如何实际得到它部署在Linux上,如果可能的话。 🙂
如果您需要其他信息,configuration,源代码让我知道,我会很乐意给它。 只是不知道该错误代码需要什么。
我会开始说我的设置与你的不一样。 我有一个ASP.NET MVC网站,在Raspberry Pi 2上使用.NET 4.5.2,运行Raspbian Jessie(Feb2016版)。 在这个发行版本股票是3.2.8,但我升级到4.2.2。
所以,我碰到了和我试图让测试网站运行时一样的错误信息。 什么工作对我来说,从我的web.config注释掉这两个<编译器>条目如下所示。
<system.codedom> <compilers> <!-- <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> --> </compilers> </system.codedom>
然后重置apache服务
sudo service apache2 restart
之后,MVC站点加载得很好。
我不能说这是一个完美的解决方案,因为我不知道为什么评论这些行的XML工作。 如果这对你有用,那很好,但是我希望有人能向我解释为什么这两行xml是这个问题的原因。
将编译器条目注释为接受的答案建议可以有效地禁用Microsoft.CodeDom.Providers.DotNetCompilerPlatform
NuGet包 – 如果您打算只在单声道上运行网站,最好卸载它,再加上Microsoft.Net.Compilers
(前者的依赖关系)完全没用 – mono可能与它不兼容,它有自己的服务API编译器。