是的,它确实。我让它在 Linux 上与 mono 一起工作。
You need mono 2.10.2+ from the stable sources from
http://ftp.novell.com/pub/mono/sources-stable/ http://ftp.novell.com/pub/mono/sources-stable/
http://download.mono-project.com/sources/mono/ http://download.mono-project.com/sources/mono/
然后,您需要将这些程序集本地复制到应用程序的 bin 目录中(从 Windows 上的 Visual Studio 获取它们):
系统.Web.Mvc.dll
系统.Web.Razor.dll
系统.Web.WebPages.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.Razor.dll
然后,您可能必须消除可能犯下的以下错误:
Error: Storage scopes cannot be created when _AppStart is executing.
Cause: Microsoft.Web.Infrastructure.dll was localcopied to the bin
directory.
Resolution: Delete Microsoft.Web.Infrastructure.dll and use the mono
version.
Error: Invalid IL code in System.Web.Handlers.ScriptModule:.ctor ():
method body is empty.
Cause: System.Web.Extensions.dll somehow gets localcopied to the bin
directory.
Resolution: Delete System.Web.Extensions.dll and use the mono version.
Error: The classes in the module cannot be loaded. Description: HTTP
500. Error processing request.
Cause: System.Web.WebPages.Administration.dll was localcopied to the bin
directory.
Resolution: Delete System.Web.WebPages.Administration.dll and unreference it
Error: Could not load type
'System.Web.WebPages.Razor.RazorBuildProvider' from assembly
'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. Description: HTTP 500. Error
processing request.
Cause: System.Web.Razor.dll is corrupt or missing (or x64 instead of x32 or vice-versa) ...
Resolution: Get an uncorrupted version of System.Web.Razor.dll and
localcopy to the bin directory
Edit
从 mono 2.12 / MonoDevelop 2.8 开始,所有这些都不再是必要的了。
请注意,在 2.10 (Ubuntu 11.10) 上,需要 localcopySystem.Web.DynamicData.dll
同样,否则您会得到一个仅在 App_Start 上发生的错误(如果您不这样做,则在第一次调用页面时您会收到 YSOD,但仅是第一次,因为只有那时 App_Start 才会被调用。)。
Note
对于带有 ASP.NET MVC4 的单声道 3.0+:
安装脚本中有一个“错误”。
或者更确切地说是不完整。
mod-mono、fastcgi-mono-server4 和 xsp4 将无法正常工作。
例如:fastcgi-mono-server4 为您提供以下调试输出:
[error] 3384#0: *101 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8000"
这是因为安装了mono3后,它使用的是framework 4.5,但是xsp、fastcgi-mono-server4和mod-mono不在4.5 GAC中,只有4.0 gac中。
要解决此问题,请使用以下 bash 脚本:
#!/bin/bash
# Your mono directory
#PREFIX=/usr
PREFIX=/opt/mono/3.0.3
FILES=('mod-mono-server4'
'fastcgi-mono-server4'
'xsp4')
cd $PREFIX/lib/mono/4.0
for file in "${FILES[@]}"
do
cp "$file.exe" ../4.5
done
cd $PREFIX/bin
for file in "${FILES[@]}"
do
sed -ie 's|mono/4.0|mono/4.5|g' $file
done
如果您通过 FastCGI(例如 nginx)使用它,您还需要修复 TransmitFile 的 chunked_encoding bug
为什么图像开头有不需要的额外字节? https://stackoverflow.com/questions/14662795/why-do-i-have-unwanted-extra-bytes-at-the-beginning-of-image/14671753#14671753(在 Mono 3.2.3 中已修复)
PS:
您可以从这里获取 3.x 的 .debs:
https://www.meebey.net/posts/mono_3.0_preview_debian_ubuntu_packages/ https://www.meebey.net/posts/mono_3.0_preview_debian_ubuntu_packages/或者自己从 github 编译它们在 Ubuntu/Debian 中安装 Mono 3.x https://stackoverflow.com/questions/13365158/installing-mono-3-0或者像这样从稳定的来源http://ubuntuforums.org/showthread.php?t=1591370 http://ubuntuforums.org/showthread.php?t=1591370
2015
您现在可以使用Xamarin 提供的包 http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
如果您需要各种最新功能,您还可以获取CI 包(每晚构建,可以这么说) http://www.mono-project.com/docs/getting-started/install/linux/ci-packages/,如果您需要最新(或几乎最新)版本
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://jenkins.mono-project.com/repo/debian sid main" | sudo tee /etc/apt/sources.list.d/mono-jenkins.list
sudo apt-get update