Open Closed

ClientProxyBase error #9385


User avatar
0
mahuwei created

Maui blazor 项目: program:

public static class MauiProgram {
    public static MauiApp CreateMauiApp() {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts => {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            });

        builder.Services.AddMauiBlazorWebView();
        ConfigureConfiguration(builder);

        builder.Services.AddApplication<KkdQueuingServiceMauiModule>(options => {
            options.Services.ReplaceConfiguration(builder.Configuration);
            options.UseAutofac();
        });

#if DEBUG
        builder.Services.AddBlazorWebViewDeveloperTools();
        builder.Logging.AddDebug();
#endif
        var app = builder.Build();
        var abpApplication = app.Services.GetRequiredService<IAbpApplicationWithExternalServiceProvider>();
        abpApplication.Initialize(app.Services);
        return app;
    }

    private static void ConfigureConfiguration(MauiAppBuilder builder) {
        var assembly = typeof(App).GetTypeInfo().Assembly;
        builder.Configuration.AddJsonFile(new EmbeddedFileProvider(assembly), "appsettings.json", false, false);
        builder.Configuration.AddJsonFile(new EmbeddedFileProvider(assembly), "appsettings.secrets.json", true, false);
    }
}

module:

[DependsOn(typeof(AbpAutofacModule),
    typeof(AbpAutoMapperModule),
    typeof(AbpAspNetCoreMvcClientCommonModule),
    typeof(AbpAspNetCoreComponentsWebModule),
    typeof(AbpIdentityProDomainSharedModule),
    typeof(AbpIdentityHttpApiClientModule),
    typeof(QueuingServiceHttpApiClientModule),
    typeof(AbpHttpClientIdentityModelModule))]
public class KkdQueuingServiceMauiModule : AbpModule {
    public override void ConfigureServices(ServiceConfigurationContext context) {
        context.Services.AddBlazorWebView();

        context.Services.AddTransient<IRemoteServiceHttpClientAuthenticator, KkdRemoteServiceHttpClientAuthenticator>();

        ConfigureAutoMapper();
        base.ConfigureServices(context);
    }

    private void ConfigureAutoMapper() {
        Configure<AbpAutoMapperOptions>(options => {
            options.AddMaps<KkdQueuingServiceMauiModule>();
        });
    }
}

调用:

@page "/counter"
@using Kkd.QueuingService.Commodities
@using Volo.Abp.DependencyInjection
@inject ICommoditiesAppService CommoditiesAppService
@inject IAbpLazyServiceProvider LazyServiceProvider

@code {
    private int _currentCount;

    private void IncrementCount() {
        _currentCount++;
    }

    private async Task GetCommoditiesAsync() {
        try {
            var tenantId = new Guid("3a1a22c2-ccbb-3f27-da9d-6e69edade96b");
            var getCommoditiesInput = new GetCommoditiesInput();
            // 出错代码
            var commodities = await CommoditiesAppService.GetListByTenantAsync(tenantId, getCommoditiesInput);
            Console.WriteLine($"Commodities count: {commodities.Count}");
        }
        catch (Exception ex) {
            Console.WriteLine($"Error fetching commodities: {ex.Message}");
        }
    }

}
  • Exception message and full stack trace:
  • System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=Volo.Abp.Http.Client StackTrace: 在 Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.get_ClientOptions() 在 Volo.Abp.Http.Client.ClientProxying\ClientProxyBase.cs 中: 第 44 行

  • Steps to reproduce the issue:
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

11 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, can you please check if your problem is the same as in this issue (https://github.com/abpframework/abp/issues/10929)?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mahuwei created

    对。

    DependsOn(typeof(AbpAutofacModule),
        typeof(AbpAutoMapperModule),
        typeof(AbpAspNetCoreMvcClientCommonModule),
        typeof(AbpAspNetCoreComponentsWebModule),
        typeof(AbpIdentityProDomainSharedModule),
        typeof(AbpIdentityHttpApiClientModule),
        typeof(QueuingServiceHttpApiClientModule),
        typeof(AbpHttpClientIdentityModelModule))]
    public class KkdQueuingServiceMauiModule : AbpModule {
    

    如下图,手工注入可以获取到啊。

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mahuwei created

    或者自定义的一个类,替换了 ClientProxyBase ?如何实现?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    你好

    Volo.Abp.Http.Client.ClientProxying.ClientProxyBase 中哪个对象是 null?

    如何复现呢?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mahuwei created
    1. abp new Kkd.App -u blazor-webapp -pwa -sm --separate-tenant-schema -dbms MySQL --no-tests -nkc -nsl -no-gdpr --version 8.3.4
    2. 手工添加一个Maui Hybrid blazor 客户端
    3. 调用后台服务
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    手工添加一个Maui Hybrid blazor 客户端

    你能分享一个项目吗? 我不太确定你的步骤。

    liming.ma@volosoft.com

    Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mahuwei created

    已发。

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    请使用https://wetransfer.com/ 分享项目

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Update MauiProgram to add .ConfigureContainer(new AbpAutofacServiceProviderFactory(new Autofac.ContainerBuilder())); will fix the NullReferenceException

    namespace Kkd.QueuingService.Maui;
    
    public static class MauiProgram {
        public static MauiApp CreateMauiApp() {
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .ConfigureFonts(fonts => {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                })
                .ConfigureContainer(new AbpAutofacServiceProviderFactory(new Autofac.ContainerBuilder()));
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mahuwei created

    好了。真郁闷啊。

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    : )

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.