Skip to content

[Bug]: Custom DI container with RxUI - Unable to resolve type IValidationTextFormatter #979

Description

@conormcg94

Prerequisites

  • I have searched open and closed issues for duplicates.
  • I am using the latest stable release.

Describe the bug 🐞

With ReactiveUI and Avalonia, I'm following the documentation to use my own DI container with a custom IDependencyResolver implementation and the AppBuilder extension .UseReactiveUIWithDIContainer().

I'm receiving an InvalidOperationException when trying to resolve ReactiveUI.Validation.Formatters.Abstractions.IValidationTextFormatter`1[System.String]. The Validation classes are not registered into my container through my resolver. They are registered in the original Splat container before AppLocator.SetLocator(dependencyResolver) switches. What's the correct way to resolve this?

Steps to reproduce

using LightInject;

internal class Program
{
    private static ServiceContainer _container;

    [STAThread]
    public static void Main(string[] args)
    {
        _container = RegisterContainer();
        var builder = BuildAvaloniaApp();
        builder.StartWithClassicDesktopLifetime(args);
    }

    public static AppBuilder BuildAvaloniaApp()
        => AppBuilder.Configure(static () => new App(_container))
            .UsePlatformDetect()
            .WithInterFont()
            .LogToTrace()
            .UseReactiveUIWithDIContainer(() => _container,
                                          x => { },
                                          c => new LightInjectResolver(c),
                                          x =>
                                          {
                                              x.WithExceptionHandler(new RootExceptionHandler());
                                          });
}

Reproduction repository

No response

Expected behavior

I would have expected an instance of ReactiveUI.Validation.Formatters.Abstractions.IValidationTextFormatter`1[System.String] to be automatically registered through my IDependencyResolver implementation. Or alternatively, a method to register RxUI.Validation types manually

Screenshots 🖼️

No response

IDE

No response

.NET version

.NET 10

Target framework(s)

No response

Operating system

No response

OS version

No response

Device

No response

ReactiveUI version

ReactiveUI.Validation=7.1.0, ReactiveUI.Avalonia=12.0.3

Additional information ℹ️

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions