ASP.. NET上的单方法没有找到PageAsyncTask

本文关键字:PageAsyncTask 方法 NET 单方法 ASP | 更新日期: 2023-09-27 18:14:18

我试图得到一些非常简单的异步调用工作,测试mono (3.4.0)运行一个'空' ASP (aspx)项目与.NET framework 4.5和async/await。但我得到以下错误:

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 h1> 台代码
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类
public class Class1
{
    public static async Task<int> Derp()
    {
        return 1;
    }
}

从tarballs构建Mono/xsp

注意:不包括unzip, make, install等复制/粘贴

#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似乎存在

ASP.. NET上的单方法没有找到PageAsyncTask

你正在使用PageAsyncTask(Func<Task>)构造函数(见MSDN),这是新的。net 4.5,还不存在于Mono,这就是为什么你得到MissingMethodException .