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

标签 c# asp.net .net linux mono

我正在尝试让一些非常简单的异步调用正常工作,以测试单声道 (3.4.0) 使用 .NET framework 4.5< 运行“空”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

最佳答案

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

关于c# - 单声道上的 ASP.NET - 找不到方法 PageAsyncTask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24913263/

相关文章:

c# - 获取类的属性和字段的值、类型和名称

c# - unity自动注入(inject)

c# - 如何在 lambda 表达式中使用局部变量

c# - C# 中的 libvlc 媒体播放器

javascript - Signalr:如何调用其名称在运行时定义的 JavaScript 函数

asp.net - Linq 查询无法转换为 SQL : how to optimize the code?

asp.net - 通过 Blob 存储的链接或通过 Controller 操作提供 PDF?

c# - HttpWebRequest、C# 和 Https

c# - 复制文件时服务器变慢

c# - 从 TypeSyntax 获取 SyntaxTree