当我在我的Fedora 20工作站上使用xsp4(来自MonoDevelop或直接)运行我的ASP.NET MVC 4网站时,我遇到以下异常:
System.Web.HttpRuntime.FinishWithException (wr={Mono.WebServer.XSPWorkerRequest}, e={System.Web.HttpException: ---> System.Web.HttpException: The pre-application start initialization method Start on type System.Web.WebPages.PreApplicationStartCode threw an exception with the following error message: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for <Module> ---> System.Security.SecurityException: No access to the given key ---> System.UnauthorizedAccessException: Access to the path "/etc/mono/registry" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String …Run Code Online (Sandbox Code Playgroud) 我在ServiceStack Web应用程序中使用WebRequest有一个非常奇怪的问题(由Mono上的XSP托管).似乎请求模块的注册以一种非常奇怪的方式工作; 我正在使用WebRequest创建HTTP请求,但它失败了,因为它无法找到该"前缀"(HTTP)的创建者.
我看到的例外情况是NotSupportedException,我能够跟踪它没有为HTTP前缀注册创建者这一事实(我正在点击https://github.com/mono/mono/blob/master/mcs/class/ System/System.Net/WebRequest.cs,第479行)
编辑:更多细节:NotSupportedException抛出WebRequest.GetCreator,它使用URL前缀作为键来选择要返回的创建者; 在我的情况下,一个HttpRequestCreator.抛出异常是因为没有为"HTTP"前缀注册的创建者(实际上,根本没有创建者).
所以我搜索了一下,挖掘了Mono源代码,发现模块是(或应该)添加到system.web的webRequestModules部分的各种*.config文件中.
我查看了我的machine.config文件,它是:
System.Net.HttpRequestCreator, System, Version=4.0.0.0
看看WebRequest Mono的来源 ,似乎前缀是从配置确实添加的,在类静态构造函数内(不是一个好的选择,恕我直言,但仍然......应该工作).
为了测试它,我尝试了添加HttpRequestCreator到system.net/webRequestModules我的web.config; 这是由XSP/Mono加载并导致重复的键异常(这是预期的,因为HttpRequestCreator应该已经加载,因为它已经存在于machine.config中).
更奇怪的是:如果我为Http添加一个模拟处理程序,就像这样:
bool res = System.Net.WebRequest.RegisterPrefix ("http", new MyHttpRequestCreator ());
Debug.Assert (res == false);
Run Code Online (Sandbox Code Playgroud)
断言有时会通过......有时候不会!(如果已经注册了相同前缀的创建者,则RegisterPrefix返回"false";我希望它总是返回false,但事实并非如此!再次,它是完全随机的)
当注册"失败"(即因为已经注册了"HTTP"前缀而返回false)时,WebRequest可以创建HTTP请求.就像调用RegisterPrefix"唤醒"静态构造函数并让它运行一样.
我很困惑:它似乎是执行WebRequest的静态构造函数时的竞争条件,但这没有意义(运行时保护带有锁的静态构造函数,IIRC)
我错过了什么?我该如何解决或解决这个问题?这是我的错(误解或遗漏某些东西)还是看起来像是一个Mono bug,因此我应该提交它吗?
细节:
mono --version Mono JIT编译器版本3.0.6(Debian 3.0.6 + dfsg-1~exp1~pre1)
(可能相关的,未回答的问题:单声道下WebRequest不支持HTTP协议)
Mono 2.10的发行说明建议使用XSP支持ASP.NET MVC 3.0和Razor.
在MonoDevelop 2.4.2(Mac OS X)中打开新创建的ASP.NET MVC 3.0默认项目(使用Visual Studio 2010创建)时,缺少以下DLL:
System.Web.Entity
System.Web.Helpers
System.Web.Mvc
System.Web.WebPages
Run Code Online (Sandbox Code Playgroud)
所有这些我都替换为从我的Windows安装中获得的DLL.项目构建,但在尝试调试项目时收到以下错误消息:
Adding applications '/:.'...
Registering application:
Host: any
Port: any
Virtual path: /
Physical path: /.../Mvc3Test/
Handling exception type TargetInvocationException
Message is Exception has been thrown by the target of an invocation.
IsTerminating is set to True
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Run Code Online (Sandbox Code Playgroud)
在进行这些替换之前,应用程序运行但显然缺少参考错误.这表明新DLL中的某些东西搞砸了XSP服务器.
我究竟做错了什么?我太简单了吗?我是Mono和MonoDevelop的新手,但我能够成功地使用当前安装的MonoDevelop创建,构建和调试MVC 2.0项目.
我正在尝试使用Mono和XSP4在我的Linux机器上启动MVC5网站.它适用于没有视图但是当我尝试渲染某些东西时它会给我带来错误.
这是我的测试代码.请注意,我没有更改任何内容,这基本上是没有EF或任何其他库的空白站点.只是裸骨MVC5 +剃刀.
public ActionResult Index()
{
// return Content("'sall good"); // works
return View();
}
Run Code Online (Sandbox Code Playgroud)
System.InvalidOperationException
找不到Razor Host Factory类型:System.Web.Mvc.MvcWebRazorHostFactory,System.Web.Mvc,Version = 5.0.0.0,Culture = neutral,PublicKeyToken = 31BF3856AD364E35
描述:HTTP 500.Error处理请求.
详细信息:非Web异常.异常来源(应用程序或对象的名称):System.Web.WebPages.Razor.
堆栈跟踪
at System.Web.WebPages.Razor.WebRazorHostFactory.CreateFactory (System.String typeName) [0x00000] in <filename unknown>:0
at System.Collections.Concurrent.ConcurrentDictionary`2+<GetOrAdd>c__AnonStorey3[System.String,System.Func`1[System.Web.WebPages.Razor.WebRazorHostFactory]].<>m__0 () [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) System.Func`1<System.Collections.Generic.KeyValuePair`2<string, System.Func`1<System.Web.WebPages.Razor.WebRazorHostFactory>>>:invoke_TResult__this__ ()
...
Run Code Online (Sandbox Code Playgroud)
我试图将Version = 5.0.0.0更改为4.0.0.0和3.0.0.0等但没有任何作用.我现在仍然得到同样的错误,大约是4.0.0.0.
有什么希望吗?
我已经从Git设置了最新的Mono(3.4.1)和最新的XSP并进行了编译.mono -V打印以下内容:
main@zombie# mono -V
Mono JIT compiler version 3.4.1 (master/89e0b25 Fri May 16 18:52:44 CEST 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
Run Code Online (Sandbox Code Playgroud)
现在我在Visual Studio 2013中创建了一个示例ASP.NET MVC项目.它包含一些基本页面.我选择使用非常简单的例子,没有认证的东西.在Windows上,它运行.在Mono上,出现以下错误:
System.TypeLoadException
Could not load type 'Mono.Web.Util.RoleManagerSectionMapper, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
at …Run Code Online (Sandbox Code Playgroud) 我有ASP.NET与MVC和Razor标记网站,我想在我的Linux VPS上运行它.
我有单声道3.2.8和xsp4 3.0.0.0版本,都来自Ubuntu存储库(已安装使用apt-get install mono-complete mono-xsp4)
当我将我的网站上传到服务器并在网站的文件夹中运行xsp4时,它会启动并打印出它正在侦听端口8080.但是,当我使用我的Web浏览器导航到我的网站时,它会显示运行时错误,xsp4会将此输出到控制台
Missing method System.Web.HttpApplication::RegisterModule(Type) in assembly
/usr/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll, referenced
in assembly /tmp/root-temp-aspnet-0/55726984/
assembly/shadow/df4b0596/52105b83_8d5b5e15_00000001/Microsoft.Owin.Host.SystemWeb.dll
Missing method RegisterAllAreas in assembly /tmp/root-temp-aspnet-
0/55726984/assembly/shadow/dc5a60b8/51013ead_8d5b5e15_00000001/<website_name>.dll, type
System.Web.Mvc.AreaRegistration
Run Code Online (Sandbox Code Playgroud)
这是一个全新的Ubuntu 14.04安装.我正在使用Visual Studio 2013在Windows上开发我的网站.任何想法如何解决这些错误?
我试图用单声道开始测试asp.net mvc应用程序,并使用XSP作为服务器.问题是我在应用程序启动时获得了关于缺少system.web.mvc的异常.
我如何获得单声道加载组件?
我从源代码(tarball)构建了Mono 3.0.2,并使用最新的tarball和最新的Github构建了XSP,但是我无法使用.net 4.5运行一个相对简单的asp.net应用程序,因为它看到' web.config中的targetFramework ="4.5"'无效.构建应用程序,并运行控制台.net 4.5应用程序工作正常.
这是有问题的web.config:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="owin:HandleAllRequests" value="true" />
<add key="owin:SetCurrentDirectory" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这是xsp4抛出的例外:
An exception has occurred while generating HttpException page:
System.NullReferenceException: Object reference not set to an instance of an object
at System.Web.Util.HttpEncoder.GetCustomEncoderFromConfig () [0x00000] in <filename unknown>:0
at System.Lazy`1[System.Web.Util.HttpEncoder].InitValue () [0x00000] in <filename unknown>:0
The …Run Code Online (Sandbox Code Playgroud) 我已经设法使用HttpListener主机在Mono上运行Katana/OWIN .
我现在正在尝试使用Microsoft.Owin.Host.SystemWebMono和XSP4.我正在使用此回购中找到的代码.它有一个Startup类:
using Owin;
namespace KatanaSystemWebTest
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseDiagnosticsPage();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在web.config中,我们将Configuration()方法定义为启动应用程序的方法:
<appSettings>
<add key="owin:AppStartup" value="KatanaSystemWebTest.Startup.Configuration, KatanaSystemWebTest" />
<add key="owin:AutomaticAppStartup" value="true" />
<add key="webpages:Enabled" value="false" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
这在Visual Studio中调试时效果很好,但在Mono上没有.我猜它是某种不会被解雇的程序集加载钩子.有什么建议?
这是运行代码的应用程序:http://peaceful-forest-6785.herokuapp.com/
我似乎无法使用xsp4或ngingx调试asp.net应用程序.官方网站说要使用:MONO_OPTIONS=--debug xsp4 --verbose.理论上调试已启用,除了我没有得到任何有关错误的信息.调用路由导致"发生错误"消息"没有别的,而我启动xsp4的控制台没有说什么.没有找到记录调试信息的方法.
一些旧帖子表明没有控制台输出是正常的,但网页中的错误应该更详细:http://lists.ximian.com/pipermail/mono-list/2005-July/027717.html.那里提出的解决方案,asp.net跟踪,似乎没有给我调试异常.在Windows上测试过它.我也试过使用mono-fastcgi-server4和nginx.stackoverflow回答说启用调试是这样的:export MONO_OPTIONS="--debug" fastcgi-mono-server-4 /applications="/:/srv/www/htdocs/mywebapp" /socket=tcp:127.0.0.1:9000.完成此操作,但没有调试输出.也不是在控制台中,也不是在mono-fastcgi-server或nginx的日志中,也不在实际页面上.
现在版本:
我正在运行Mono JIT编译器版本4.0.2(Stable 4.0.2.5/c99aa0c Wed Jun 24 10:33:52 UTC 2015)
Copyright(C)2002-2014 Novell,Inc,Xamarin Inc和Contributors.www.mono-proj ect.com
TLS: __thread
SIGSEGV: normal
Notifications: epoll
Architecture: armel,vfp+hard
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
Run Code Online (Sandbox Code Playgroud)
xsp4 --version
Mono.WebServer2.dll 0.4.0.0
(c)(c)2002-2011 Novell,Inc.
在应用程序.NET 4.0中嵌入ASP.NET服务器的类.
关于树莓派2的Debian 7.8.
谢谢.
mono ×10
xsp ×10
asp.net ×3
asp.net-mvc ×3
katana ×2
linux ×2
owin ×2
c# ×1
debugging ×1
fedora ×1
monodevelop ×1
servicestack ×1
system.web ×1
xsp4 ×1