C# 如何解决从Program.cs调用Startup.cs的问题?

C# 如何解决从Program.cs调用Startup.cs的问题?,c#,razor,blazor,startup,C#,Razor,Blazor,Startup,编辑 我正在使用Blazor WASM项目。我正在尝试使用TG.Blazor.indexeddbnuget包为我的项目创建索引数据库。我在我的项目中创建Startup.cs。我在Program.cs和Startup.cs中有一些错误 错误CS0246找不到类型或命名空间名称“IComponentsApplicationBuilder”(是否缺少using指令或程序集引用?) Starup.cs using System.Collections.Generic; using Microsoft.E

编辑

我正在使用Blazor WASM项目。我正在尝试使用TG.Blazor.indexeddbnuget包为我的项目创建索引数据库。我在我的项目中创建Startup.cs。我在Program.cs和Startup.cs中有一些错误

错误CS0246找不到类型或命名空间名称“IComponentsApplicationBuilder”(是否缺少using指令或程序集引用?)

Starup.cs

using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using TG.Blazor.IndexedDB;


 namespace WebApplication
{
public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddIndexedDB(dbStore =>
        {
            dbStore.DbName = "TheFactory";
            dbStore.Version = 1;

            dbStore.Stores.Add(new StoreSchema
            {
                Name = "Employees",
                PrimaryKey = new IndexSpec { Name = "id", KeyPath = "id", Auto = true },
                Indexes = new List<IndexSpec>
                {
                    new IndexSpec{Name="firstName", KeyPath = "firstName", Auto=false},
                    new IndexSpec{Name="lastName", KeyPath = "lastName", Auto=false}

                }
            });
            dbStore.Stores.Add(new StoreSchema
            {
                Name = "Outbox",
                PrimaryKey = new IndexSpec { Auto = true }
            });
        });
    }
//error here 
    public void Configure(IComponentsApplicationBuilder app)
    {
        app.AddComponent<App>("app");
    }
}
 }
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using TG.Blazor.IndexedDB;


 namespace WebApplication
{
public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = WebAssemblyHostBuilder.CreateDefault(args);
        builder.RootComponents.Add<App>("#app");

        builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

        await builder.Build().RunAsync();
       
        // error at Run()
        CreateHostBuilder(args).Build().Run();
    }
    public static WebAssemblyHostBuilder CreateHostBuilder(string[] args) =>
        //error at BlazorWebAssemblyHost
       BlazorWebAssemblyHost.CreateDefaultBuilder()
           .UseBlazorStartup<Startup>();
}
}
使用System.Collections.Generic;
使用Microsoft.Extensions.DependencyInjection;
使用TG.Blazor.IndexedDB;
命名空间Web应用程序
{
公营创业
{
public void配置服务(IServiceCollection服务)
{
services.AddIndexedDB(dbStore=>
{
dbStore.DbName=“TheFactory”;
dbStore.Version=1;
添加(新的StoreSchema)
{
Name=“Employees”,
PrimaryKey=newindexspec{Name=“id”,KeyPath=“id”,Auto=true},
索引=新列表
{
新索引spec{Name=“firstName”,KeyPath=“firstName”,Auto=false},
新索引spec{Name=“lastName”,KeyPath=“lastName”,Auto=false}
}
});
添加(新的StoreSchema)
{
Name=“发件箱”,
PrimaryKey=newindexSpec{Auto=true}
});
});
}
//这里出错
公共无效配置(IComponentsApplicationBuilder应用程序)
{
app.AddComponent


这是Reshiru.Blazor.IndexDB的启动页

它贬值了,过时了,过时了。在我的书中,这意味着不要靠近它


尝试
WebHost
取而代之。@JevonKendon我已经尝试过了&仍然错误不确定。我只是运行了'dotnet new blazorserver-o BlazorApp--no https`来生成一个新的blazor项目。
Host
找到了。我可能建议您从那里开始,并更新生成的代码。从您那里有2个
.Build().RunAsync()
。那不可能是对的。注意到了&我已经用TG.Blazor测试过了&有上述问题