2014-07-23 7 views
0

J'essaie de faire fonctionner un appel asynchrone très simple, pour tester mono (3.4.0) en exécutant un projet ASP vide (aspx) avec .NET framework 4.5 et async/await. Mais je reçois l'erreur suivante:ASP.NET sur mono - méthode non trouvée PageAsyncTask

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 

sortie 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 

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

classe Bibliothèque

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

Mono/XSP construit à partir tarballs

Note: Décompressez exclus, assurez-vous, installez etc de copier/coller

#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 

Test sur Ubuntu 14.04, Trusty Tahr

Quelqu'un peut-il me dire ce que J'ai foiré? Parce que PageAsyncTask appears to exist

Répondre

1

Vous utilisez le constructeur PageAsyncTask(Func<Task>) (voir MSDN) qui est nouveau dans .NET 4.5 et n'existe pas sur Mono encore, c'est pourquoi vous obtenez le MissingMethodException.

Questions connexes