Mono+Jexus部署MVC的各种坑

  别人提到的这里不赘述,只说查了好久才知道的。

1号坑:System.IO.FileNotFoundException Could not find file "roslyn\csc.exe".
详细信息如下:

System.IO.FileNotFoundException
Could not find file "/var/www/defalut/bin\roslyn\csc.exe".

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) <0x41aaab70 + 0x006e7> in     <filename unknown>:0
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) <0x41bba470 + 0x00053> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) <0x41bc4b50 + 0x0003f> in <filename unknown>:0
  at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.get_CompilerName () <0x41e0fb40 + 0x00086> in <filename unknown>:0
  at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) <0x41e1d600 + 0x005ce> in     <filename unknown>:0 

只贴其中的一部分,但是大致一看也能看出路径有问题,问题的原因:

http://www.mono-project.com/docs/advanced/iomap/

Mono官方网站给出的解释及解决方案如下:

The Problem

Windows developers are used to a case-insensitive file system, which means that they might create a file called “mydata” in one place, and try to access it somewhere else as “MyData” or as “MYDATA”. This breaks on most Unix setups because Unix is case sensitive[1].

Another problem is that developers sometimes hardcode the directory separator character in their source code (“\”) instead of using Path.DirectorySeparator and using Path.Combine for combining this paths. This is a problem because “\” is a valid file name components on Unix. This means that if an application hardcodes for example “Logs\access_log”, in Unix this will not store the contents in the “Logs” directory as the file “access_log”. Instead, it will store the results in a file called “Logs\access_log”.

Only a few applications cope with drive letters, but they might still pose a problem as the colon is a valid filename in Unix, which means that “A:\file” is a valid filename in the current directory.

Although .NET provides the tools to write code that is portable, in practice, they do not use these features (the exception is Path.Combine, which some people use, as it is genuinely useful on its own).

The Usual Solution

When moving applications from Windows to Linux, it is always necessary to run the application, run its test suite, and validate that the application works as intended. With the path problems described above, the process above included a number of iterations to fix the assumptions made by programmers about the file system.

This process could be time consuming, because identifying where the mistakes were made could take some time, the program might fail with FileNotFound exceptions (when referencing files that were not there), data would show up empty (listing contents of a directory that had nothing, as all the data went elsewhere) but it was doable.

This process works as long as you have the source code to all the components that you are porting, but if you were using a third-party library that you had no source code for, you would not be able to fix the problems.

The New Solution

Mono now has a portability layer into Mono that will address those problems without requiring changes to your code. This will remove a large component of the porting cycle as a whole class of obnoxious problems are gone.

The new portability framework is enabled by setting the environment variable MONO_IOMAP (which we will likely rename to something shorter) to one of the following values:

  • case: makes all file system access case insensitive.
  • drive: strips drive name from pathnames.
  • all: enables both case and drive.

In addition, if any of those options are enabled, the directory separator mapping is also turned on. So this basically means that you have to type this, or include this in your script that launches your application:

   $ export MONO_IOMAP=all
   $ mono myapp.exe

For ASP.NET applications hosted with mod_mono, you can add the following directive to your Apache configuration file:

 MonoSetEnv MONO_IOMAP=all

This new feature appeared in Mono 1.1.18 and is available in all new Mono 1.2.x versions as well.

The downside is that Mono will have to do some extra work when coping with your file system, to search for case insensitive file names. So if your application is still a portable application, you will be much better off without this switch.

[1] Some Linux file systems are case insensitive, and some folks have used a combination of hacks, including doing loopback CIFS mounts to get case sensitivity issues out of the way; OS X does not have this particular problem, but it still has the others.

2号坑:System.InvalidOperationException  Process has not been started.

详细信息如下:

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.
Exception stack trace:
  at System.Diagnostics.Process.get_ExitCode () <0x414b69b0 + 0x000a3> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ExitCode ()
  at System.CodeDom.Compiler.Executor.InternalExecWaitWithCapture (System.String cmd, System.String currentDir, System.CodeDom.Compiler.TempFileCollection tempFiles, System.String& outputName, System.String& errorName) <0x414b3ec0 + 0x00403> 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) <0x414b3c00 + 0x00057> 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) <0x414b37e0 + 0x0010b> in <filename unknown>:0
  at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) <0x414b03e0 + 0x005ef> in <filename unknown>:0
  at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) <0x414b0250 + 0x000c7> in <filename unknown>:0
  at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) <0x414b00b0 + 0x00049> in <filename unknown>:0
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) <0x4149bd40 + 0x00979> in <filename unknown>:0
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) <0x4149bd00 + 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) <0x414913e0 + 0x0097b> in <filename unknown>:0
  at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) <0x41444aa0 + 0x0050b> in <filename unknown>:0
  at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) <0x41444520 + 0x000ff> in <filename unknown>:0
  at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) <0x41443e20 + 0x0008f> in <filename unknown>:0
  at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) <0x41443a50 + 0x00017> in <filename unknown>:0
  at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) <0x413dd430 + 0x003f3> in <filename unknown>:0 

待续···

时间: 2024-12-05 18:06:32

Mono+Jexus部署MVC的各种坑的相关文章

ubuntu Mono+Jexus 部署到 ASP.NET MVC 5

之前搞了很多次都是卡在了razor那个异常哪里,今天心血来潮就在试一试,一试竟然成功了,激动的我赶紧记录下历程.废话不说,走起... ubuntu 16.04 安装mono(最新版 5.14.0) 官网地址 https://www.mono-project.com/download/stable/#download-lin-ubuntu 首先 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0

Ubuntu(Linux) + mono + jexus +asp.net MVC3 部署

感谢  张善友 的建议,我把 微信订餐  由nginx 改成 jexus,目前运行状况来说,确实稳定了很多,再次感谢. 部署步骤参考 jexus官网:http://www.jexus.org/ http://www.linuxdot.net/bbsfile-3500 启动路径改成 var/www,所以应该创建一个www的文件夹 sudo mkdir /var/www 建议更改一下权限吧,因为这个文件夹需要共享,进行远程部署 sudo chmod 777 /var/www 需要导入mvc的dll支

ASP.NET Linux部署(2) - MS Owin + WebApi + Mono + Jexus

原文:ASP.NET Linux部署(2) - MS Owin + WebApi + Mono + Jexus ASP.NET Linux部署(2) - MS Owin + WebApi + Mono + Jexus 本文承接我的上一篇博文: ASP.NET 5 Linux部署,那篇文章主要是针对最新的ASP.NET 5的,但在随后的研究中,我对这种娱乐型的部署依然不是非常满意,当然其主要原因是因为ASP.NET 5 依然处于RC版本,并不十分成熟. 但可以预见到的是,就算本月ASP.NET 5

Mono+Jexus让C#运行在Linux(centos7_x64),学习笔记

h2 { background: #6fa833 none repeat scroll 0 0 !important; color: #fff; font-family: "微软雅黑", "宋体", "黑体", Arial; margin-bottom: 5px; padding-left: 15px } h3 { background-color: #f5f5f5; border-left: 13px solid #6fa833; color:

通过Jexus 部署 dotnetcore

通过Jexus 部署 dotnetcore版本MusicStore 示例程序 ASPNET Music Store application 是一个展示最新的.NET 平台(包括.NET Core/Mono等)上使用MVC 和Entity Framework的示例程序,本文将展示如何在CentOS上运行.NET Core版本的MusicStore,并通过Jexus对外发布. 上篇文章 <结合Jexus + Kestrel 部署 asp.net core 生产环境> 我们已经部署好了.NET Co

阿里云Ubuntu14.04配置Mono+Jexus

总所周知,ASP.NET是微软公司的一项技术,是一个网站服务端开发的一种技术,它可以在通过HTTP请求文档时再在Web服务器上动态创建它们,就是所谓动态网站开发,它依赖运行于 IIS 之中的程序 .但是从成本上面来讲,Linux(开源)系统的花费比Windows Server系列少得多.因此,更多的企业愿意采用Linux作为服务器系统.由于ASP.NET依赖于IIS,导致有部分创业型公司在技术选型上会将ASP.NET筛选掉.我们伟大的程序猿,为了能让ASP.NET运行在Linux系统上,Mono

Jexus部署Asp.Net Core项目

在之前的我的博客项目中,我将.net Core发布到Cent OS 上,使用的Nginx代理以及Supervisor进程守护,看过我的博客的童鞋,也会发现,这种方式比较麻烦,光命令行就看的头大,总共部署了两次还是三次,可是每次一样都是要翻博客翻资料,想想还是IIS好用,点几下鼠标就完成了,没有这么多步骤.之前也一直想尝试下使用Jexus部署我的项目,也一直没有时间搞,今天趁着外面下雨,就仔细学习下这个东东. Jexus百度百科: Jexus 即 Jexus Web Server,简称JWS,是L

Win7下IIS部署MVC项目的一些问题

最近换了新电脑,装了系统和软件之后,部署MVC项目发现了一系列的错误和问题,记录如下: IIS7/8 HTTP Error 500.19错误 0x80070021 如果IIS7.0是在VS安装之后安装的话,那么需要添加IIS7.0对ASP.NET文件的支持,否则会出现aspx文件无法识别的MIME 错误,或者以上问题. 方法:打开和关闭系统功能--->Internet信息服务-->万维网服务--->应用程序开发功能—>勾选asp.net 如果还不行则: 若在安装完毕NET Fram

windows 7 + virtualbox安装centos+mono+jexus

1. 下载安装virtualbox和virtualbox extension 2. 创建并安装centos虚拟机 3. 下载并安装libgdiplus,gdi+库 4. 下载并安装Mono 5. 下载并安装Gtk-sharp,GUIi库(可选,如不需运行桌面程序,可以不装) 6. 下载并安装MonoDeveloper(可选,可以在windows下面写程序,然后拷贝到centos中运行,MonoDeveloper运行web的时候会默认占用8080端口) 7. 下载并安装xsp,https://gi