我尝试在本地运行 firebase 函数,但收到错误:
Exception while executing function: Functions.TestMe. Microsoft.Azure.WebJobs.Host: One or more errors occurred. Exception binding parameter 'req'. mscorlib: Cannot create an abstract class.
我在 VSCode 中有一个 azure 的云函数项目,只有这个函数:
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
using MongoDB.Bson;
using MongoDB.Driver;
namespace Learning.Platform
{
public static class TestMe
{
[FunctionName("TestMe")]
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequest req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
var db = new MongoClient(/*snipped*/);
var hey = db.GetDatabase("dude").GetCollection<object>("hey");
return (ActionResult)new OkObjectResult($"Hello, {hey}");
}
}
}
我本以为这会起作用,因为它是 azure 函数的一个相当基本的示例。
我使用的是 Azure .net SDK 版本 2.9、Azure Tools 1.3.0 和 .Net Core 2.0 框架。
最佳答案
我出于沮丧而放弃了,卸载了.net core框架和azure工具,然后重新安装了它们。
问题已自行解决。
关于c# - 无法创建抽象类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48478543/