简体   繁体   中英

ASP.NET on mono - method not found PageAsyncTask

I'm trying to get some really simple async call working, to test mono ( 3.4.0 ) running an 'empty' ASP (aspx) project with .NET framework 4.5 and async/await. But I'm getting the following error:

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 output:

>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

Code 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>

Code-behind

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());
        }
    }
}

Library class

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

Mono / xsp built from tarballs

Note: Excluded unzip, make, install etc from copy/paste

#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

Testing on Ubuntu 14.04, Trusty Tahr

Can anyone tell me what I messed up? Because PageAsyncTask appears to exist

您正在使用PageAsyncTask(Func<Task>)构造函数(请参见MSDN ),该构造函数是.NET 4.5中的新增功能,在Mono上尚不存在,这就是为什么会得到MissingMethodException

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM