[英]How to access static classes in a .net asp.core library from f#
I'm trying to translate the following: 我正在尝试翻译以下内容:
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
namespace AspNetCoreDotNetCore2App
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
}
to f# 到F#
I've come up with this: 我想出了这个:
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Hosting
type Program =
static member BuildWebHost =
fun (args : string []) ->
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build()
static member Main(args : string []) =
BuildWebHost(args).Run()
but get an error when building: 但是在构建时出现错误:
D:\documents\code\rhea\Program.fs(318,13): error FS0039: The value, namespace, type or module 'WebHost' is not defined.
Maybe you want one of the following: IWebHost WebHostBuilder WebHostDefaults WebHostExtensions Web
D:\documents\code\rhea\Program.fs(323,9): error FS0039: The value or constructor 'BuildWebHost' is not defined. Maybe y
ou want one of the following: Builder IWebHost
Here's the documentation of WebHost: https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.webhost?view=aspnetcore-2.1 这是WebHost的文档: https ://docs.microsoft.com/zh-cn/dotnet/api/microsoft.aspnetcore.webhost ? view = aspnetcore-2.1
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Hosting
let createWebHostBuilder args =
WebHost
.CreateDefaultBuilder(args)
.UseStartup<Startup>();
[<EntryPoint>]
let main args =
CreateWebHostBuilder(args).Build().Run()
0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.