单声道上的ASP.NET - 找不到PageAsyncTask的方法

时间:2014-07-23 14:29:22

标签: c# asp.net .net linux mono

我试图让一些非常简单的异步调用工作,以测试运行“空”的单声道(3.4.0)。带有.NET framework 4.5和async / await的ASP(aspx)项目。但我收到以下错误:

System.MissingMethodException
Method not found: 'System.Web.UI.PageAsyncTask..ctor'.

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.
Exception stack trace:
  at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessLoad () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessPostData () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 

Version Information: 3.4.0 (tarball Wed Jul 23 13:38:38 UTC 2014); ASP.NET Version: 4.0.30319.17020

xsp4输出:

>xsp4
Listening on address: 0.0.0.0
Root directory: /var/www/html
Listening on port: 8080 (non-secure)
Hit Return to stop the server.
Missing method System.Web.UI.PageAsyncTask::.ctor(Func`1<Task>) in assembly /opt/mono-3.4/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll, referenced in assembly /tmp/root-temp-aspnet-0/9c64be87/assembly/shadow/1ea469ab/b16a2f99_afce4632_00000001/WebApplication1.dll

代码aspx

<%@ Page Language="C#" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" Async="true" %>
<%@ Import Namespace="MahLib" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>

代码隐藏

using System;
using System.Threading.Tasks;
using System.Web.UI;
using MahLib;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterAsyncTask(new PageAsyncTask(LoadSomeData));
        }

        public async Task LoadSomeData()
        {
            Response.Write(await Class1.Derp());
        }
    }
}

图书馆班级

public class Class1
{
    public static async Task<int> Derp()
    {
        return 1;
    }
}

从tarball构建的Mono / xsp

注意:从复制/粘贴中排除解压缩,制作,安装等

#Mono
wget http://origin-download.mono-project.com/sources/mono/mono-3.4.0.tar.bz2
./configure --prefix=/opt/mono-3.4

#xsp
wget https://github.com/mono/xsp/archive/3.0.11.tar.gz
#Via autogen.sh
run aclocal -I build/m4/shamrock -I build/m4/shave $ACLOCAL_FLAGS
run autoconf
run automake --gnu --add-missing --force --copy
./configure --enable-maintainer-mode --prefix=/opt/mono-3.4

Ubuntu 14.04, Trusty Tahr

上进行测试

谁能告诉我我搞砸了什么?因为PageAsyncTask appears to exist

1 个答案:

答案 0 :(得分:1)

您使用的是PageAsyncTask(Func<Task>)构造函数(请参阅MSDN),它是.NET 4.5中的新增功能,但尚未在Mono上存在,这就是您获得MissingMethodException的原因