Skip to content

"Cannot access a disposed object" after clicking image in [inferencer] gallery panel #1367

Description

@richardm1

What happened?

Drag-and-drop image from the gallery (right side of inferencer) into the prompt window:

025-08-31 01:31:20.7650|INFO|StabilityMatrix.Avalonia.ViewModels.Base.InferenceTabViewModelBase|Loading image metadata from LocalImageFile at '"/mnt/M9200/SM/Data/Images/Inference/lustifySDXLNSFW_oltFIXEDTEXTURES-DPM++ 2M SDE Karras-1392122868-00-57-05.png"'
2025-08-31 01:31:20.7650|INFO|StabilityMatrix.Avalonia.ViewModels.Base.InferenceTabViewModelBase|Loading Project State (Type: "InferenceTextToImageViewModel")
2025-08-31 01:31:20.7695|WARN|StabilityMatrix.Avalonia.ViewModels.Base.InferenceTabViewModelBase|Failed to load image from context drop|System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'IServiceProvider'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
   at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get(Type serviceType)
   at StabilityMatrix.Avalonia.ViewModels.Inference.StackViewModelBase.LoadStateFromJsonObject(JsonObject state)
   at StabilityMatrix.Avalonia.ViewModels.Base.LoadableViewModelBase.LoadStateFromJsonObject(JsonObject state)
   at Avalonia.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
   at Avalonia.Threading.Dispatcher.Invoke(Action callback)
   at StabilityMatrix.Avalonia.ViewModels.Base.InferenceTabViewModelBase.LoadImageMetadata(String imageFilePath, ValueTuple`5 metadata)
   at StabilityMatrix.Avalonia.ViewModels.Base.InferenceTabViewModelBase.LoadImageMetadata(LocalImageFile localImageFile)
   at StabilityMatrix.Avalonia.ViewModels.Base.InferenceTabViewModelBase.<>c__DisplayClass30_0.<Drop>b__0()

Seems to happen at random. I can tell it's about to happen when I flip to an existing generation tab and the model (checkpoint) selector is blank.

Note the .PNG generation appears to be fine (i.e. no metadata corruption). Drag-and-drop of said image works if I restart SM.

Steps to reproduce

See above.

Relevant logs

pasted above

Version

v2.15.0-pre.2+fdf2ae0

What Operating System are you using?

Linux

Activity

  1. richardm1 commented on Sep 3, 2025

    @richardm1
    Author

    I think I've tracked it down.

    2025-09-02 20:07:46.5540|DEBUG|StabilityMatrix.Avalonia.Services.InferenceClientManager|Model index changed, reloading shared properties for Inference
    2025-09-02 20:07:46.6364|INFO|StabilityMatrix.Core.Services.ModelIndexService|Loaded 12 models from database in 383.47ms
    

    I'd just deleted a checkpoint (not the one I was using at the time).

  2. richardm1 commented on Sep 10, 2025

    @richardm1
    Author

    I'm NOT messing with any models tonight and still getting this when clicking on an image in the inferencer gallery.

    2025-09-09 23:47:13.7331|WARN|StabilityMatrix.Avalonia.Program|Unhandled "ObjectDisposedException": "Cannot access a disposed object.
    Object name: 'IServiceProvider'."|System.ObjectDisposedException: Cannot access a disposed object.
    Object name: 'IServiceProvider'.
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get(Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get[TService]()
       at StabilityMatrix.Avalonia.ViewModels.Inference.ImageFolderCardViewModel.OnImageClick(LocalImageFile item)
       at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
       at Avalonia.Threading.DispatcherOperation.Execute()
       at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
       at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
       at Avalonia.Threading.Dispatcher.Signaled()
       at Avalonia.X11.X11PlatformThreading.CheckSignaled()
       at Avalonia.X11.X11PlatformThreading.RunLoop(CancellationToken cancellationToken)
       at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
       at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
       at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
       at StabilityMatrix.Avalonia.Program.Main(String[] args)
    
  3. richardm1 commented on Oct 16, 2025

    @richardm1
    Author

    Still present in 2.15.2. Can't zero-in on what [sequence of] actions causes this. This time I clicked on a photo in the inferencer's gallery (vertical scroll list on the right).

    ## Exception
    ```ObjectDisposedException: Cannot access a disposed object.
    Object name: 'IServiceProvider'.```
    ### Sentry ID
    [`7ba6c849`](https://stability-matrix.sentry.io/issues/?query=id%3A7ba6c8490f974e53be8d9023f431de1e&referrer=sm-app-ex&statsPeriod=90d)
    ### Stack Trace
    ```   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get(Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get[TService]()
       at StabilityMatrix.Avalonia.ViewModels.Inference.ImageFolderCardViewModel.OnImageClick(LocalImageFile item)
       at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
       at Avalonia.Threading.DispatcherOperation.Execute()
       at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
       at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
       at Avalonia.Threading.Dispatcher.Signaled()
       at Avalonia.X11.X11PlatformThreading.CheckSignaled()
       at Avalonia.X11.X11PlatformThreading.RunLoop(CancellationToken cancellationToken)
       at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
       at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
       at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
       at StabilityMatrix.Avalonia.Program.Main(String[] args)```
    
  4. richardm1 commented on Oct 21, 2025

    @richardm1
    Author

    Still present in 2.15.3.

    ## Exception
    ```ObjectDisposedException: Cannot access a disposed object.
    Object name: 'IServiceProvider'.```
    ### Sentry ID
    [`7be9e969`](https://stability-matrix.sentry.io/issues/?query=id%3A7be9e96910454567b93fd678c1be6fe1&referrer=sm-app-ex&statsPeriod=90d)
    ### Stack Trace
    ```   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get(Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get[TService]()
       at StabilityMatrix.Avalonia.ViewModels.Inference.ImageFolderCardViewModel.OnImageClick(LocalImageFile item)
       at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
       at Avalonia.Threading.DispatcherOperation.Execute()
       at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
       at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
       at Avalonia.Threading.Dispatcher.Signaled()
       at Avalonia.X11.X11PlatformThreading.CheckSignaled()
       at Avalonia.X11.X11PlatformThreading.RunLoop(CancellationToken cancellationToken)
       at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
       at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
       at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
       at StabilityMatrix.Avalonia.Program.Main(String[] args)```
    
  5. richardm1 commented on Dec 17, 2025

    @richardm1
    Author

    2.15.4 (still on Linux):

    
    ## Exception
    ```ObjectDisposedException: Cannot access a disposed object.
    Object name: 'IServiceProvider'.```
    ### Sentry ID
    [`96e3a002`](https://stability-matrix.sentry.io/issues/?query=id%3A96e3a002082d4f16b5063d184b7a17d9&referrer=sm-app-ex&statsPeriod=90d)
    ### Stack Trace
    ```   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get(Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get[TService]()
       at StabilityMatrix.Avalonia.ViewModels.Inference.ImageFolderCardViewModel.OnImageClick(LocalImageFile item)
       at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
       at Avalonia.Threading.DispatcherOperation.Execute()
       at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
       at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
       at Avalonia.Threading.Dispatcher.Signaled()
       at Avalonia.X11.X11PlatformThreading.CheckSignaled()
       at Avalonia.X11.X11PlatformThreading.RunLoop(CancellationToken cancellationToken)
       at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
       at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
       at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
       at StabilityMatrix.Avalonia.Program.Main(String[] args)```
    
  6. changed the title [-]"Cannot access a disposed object" after image drag-and-drop[/-] [+]"Cannot access a disposed object" after clicking image in [inferencer] gallery panel[/+] on Dec 17, 2025
  7. Pekururu commented on Jan 3, 2026

    @Pekururu

    Issue still present. Attached a screenshot to show the state when the error occurs. What I did what triggered it: Tried dragging the top item on the inference gallery tab to Img2Img. It's clearly there in the inference folder.

    ## Exception
    ```ObjectDisposedException: Cannot access a disposed object.
    Object name: 'IServiceProvider'.```
    ### Sentry ID
    [`868e4432`](https://stability-matrix.sentry.io/issues/?query=id%3A868e44327d214c759e9cef0a860f49a2&referrer=sm-app-ex&statsPeriod=90d)
    ### Stack Trace
    ```   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get(Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get[TService]()
       at StabilityMatrix.Avalonia.ViewModels.Inference.ImageFolderCardViewModel.OnImageClick(LocalImageFile item)
       at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
       at Avalonia.Threading.DispatcherOperation.Execute()
       at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
       at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
       at Avalonia.Threading.Dispatcher.Signaled()
       at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
       at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
       at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken)
       at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
       at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
       at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
       at StabilityMatrix.Avalonia.Program.Main(String[] args)```
    
    Image
  8. github-actions commented on Mar 5, 2026

    @github-actions

    This issue is stale because it has been open 60 days with no activity. Remove the stale label or comment, else this will be closed in 7 days.

  9. added
    staleStale issue or inactive for long period of time
    on Mar 5, 2026
  10. richardm1 commented on Mar 7, 2026

    @richardm1
    Author

    Please un-stale. Still seeing this on 2.16.0-dev.2 on Linux.

  11. removed
    staleStale issue or inactive for long period of time
    on Mar 7, 2026
  12. github-actions commented on May 6, 2026

    @github-actions

    This issue is stale because it has been open 60 days with no activity. Remove the stale label or comment, else this will be closed in 7 days.

  13. added
    staleStale issue or inactive for long period of time
    on May 6, 2026
  14. Pekururu commented on May 6, 2026

    @Pekururu

    Still present. See attached logzip.

    stabilitymatrix-log-2026-05-07-00-52-00.zip

  15. removed
    staleStale issue or inactive for long period of time
    on May 7, 2026
  16. richardm1 commented on Jun 2, 2026

    @richardm1
    Author

    This was from simply clicking an image in the Galley panel (inferencing page). v2.16.0-pre.1

    The good news is it seems the "Continue" button will indeed let me continue.

    ## Exception
    ```ObjectDisposedException: Cannot access a disposed object.
    Object name: 'IServiceProvider'.```
    ### Sentry ID
    [`213d7346`](https://stability-matrix.sentry.io/issues/?query=id%3A213d7346256f4eaf8cdd39157472b815&referrer=sm-app-ex&statsPeriod=90d)
    ### Stack Trace
    ```   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get(Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get[TService]()
       at StabilityMatrix.Avalonia.ViewModels.Inference.ImageFolderCardViewModel.OnImageClick(LocalImageFile item)
       at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()```
    
  17. Pekururu commented on Jun 22, 2026

    @Pekururu

    Still present unfortunatly. But continue does work thankfully.

    Exception

    Object name: 'IServiceProvider'.```
    ### Sentry ID
    [`c386aa22`](https://stability-matrix.sentry.io/issues/?query=id%3Ac386aa224ca24062935e8b97c8f01148&referrer=sm-app-ex&statsPeriod=90d)
    ### Stack Trace
    ```   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get(Type serviceType)
       at StabilityMatrix.Avalonia.Services.ScopedServiceManager`1.Get[TService]()
       at StabilityMatrix.Avalonia.ViewModels.Inference.ImageFolderCardViewModel.OnImageClick(LocalImageFile item)
       at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
       at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
       at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()```
    
  18. github-actions commented on Aug 22, 2026

    @github-actions

    This issue is stale because it has been open 60 days with no activity. Remove the stale label or comment, else this will be closed in 7 days.

  19. added
    staleStale issue or inactive for long period of time
    on Aug 22, 2026
  20. added a commit that references this issue on Aug 29, 2026
  21. github-actions commented on Aug 30, 2026

    @github-actions

    This issue was closed because it has been stale for 7 days with no 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 workingstaleStale issue or inactive for long period of time

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions