Questions tagged [objectdisposedexception]

The exception that is thrown when an operation is performed on a disposed object.

190 questions
0
votes
6 answers

Opened SerialPort crashes C# application

The computer is connected to measuring device via a physical COM1. I have simple form where I open a serial port, tell the device that I'm alive and occasionally the device sends data. (every some minutes) Thread _readThread = new…
Stefan Teitge
  • 716
  • 3
  • 10
  • 21
0
votes
0 answers

ObjectDisposedException after disposing of the control

I have a real world need for what I'm going to ask, but to make it simple I've boiled the issue down to this. Create a C# windows forms application project Add a textbox and a button to the form. Add a Leave event to the textbox. Add a Click event…
0
votes
1 answer

Cannot access a disposed object. Object name: 'FileBufferingReadStream' Error while uploading multiple files

I am trying to write a Razor Page which accepts multiple files and save them in a table. The Files uploaded through the following partial page - @model CommonApplicationDTO
Name Date of…
Dibakar
  • 139
  • 4
  • 15
0
votes
1 answer

c# StringContent in MultipartFormDataContent seems to have been disposed at the point of doing PostAsync

I have the following pretty simple class for sending some data to an external supplier, what seems to happen is at the point of the _httpClient.PostAsync call something(?) has already disposed of the StringContent objects - public async…
beakersoft
  • 2,316
  • 6
  • 30
  • 40
0
votes
0 answers

.Net6 C# WinForm app crashes w/Cannot access a disposed object. Object name: 'Panel'

I have 2 projects in my solution. One is my Launcher (Relevant Code Only): namespace Launcher { public partial class LauncherForm: Form { private static MyApplication.AppForm? AppForm = null; private void…
Taldren
  • 11
  • 2
0
votes
2 answers

Task.Run causes "Cannot access a disposed context instance" exception

Using Task.Run causes "object disposed" exception in my application if using DbContext. The code looks like (see the whole chain): UserController.cs [Route("api/[controller]")] public class UsersController : ControllerBase { private readonly…
0
votes
0 answers

A RouteState was used after being disposed Error

Let me explain my Flutter structure first. I have a flutter main application and another application added as a package that has a different routing method and navigation. app behavior is when I click on a card on the main app it will get me to the…
0
votes
0 answers

C# IFeatureCollection has been disposed

I'm trying to make a cart in session, but there was a problem, help me please I'm not using HttpContextAccessor Is my class My exception
0
votes
0 answers

In memory database disposed by the initial use

I'm trying to use In-Memory Database. I can read from it, but if I try to add something it throws an exception of type System.ObjectDisposedException.I cant really spot differences with working examples around. I'm using EF Core, .net core 3.1.…
0
votes
1 answer

Microsoft bot framework session timeout after user inactivity

I'm working on a scenario where the user is warned after 1 minute of inactivity and after another, 1-minute chat will auto close. Callback is successfully invoked after 1 minute but when I'm using turnContext to send a message to user then it shows…
0
votes
0 answers

MemoryCache's Callback runs on new thread & classes are “dependency injected” as Transients, DBContext gives “Cannot access a disposed context” error

( Related Posting: Why is DBContext is disposed after putting it in IMemoryCache (.NET Core / EF Core) ) ( Related Posting: Cannot access a disposed object with MemoryCache ) Here is info about our technical development environment : Microsoft…
0
votes
1 answer

XNA SpriteBatch.End() ObjectDisposedException

I am having some issues with a thrown exception. Below is the draw method from the XNA loop. protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.White); checkInitialization(); // Makes sure that the…
Godric Seer
  • 359
  • 4
  • 16
0
votes
1 answer

System.ObjectDisposedException when trying to access DataContext

I am trying to get some data from a repository using DbContext. For some reason I keep getting a System.ObjectDisposedException. In my whole code I am not disposing anything and I do not use using statements in the concerning class. This is an…
0
votes
1 answer

Handling ObjectDisposedExceptions on disconnected WCF channels

When a method is called on a WCF channel that has been disconnected for some reason, it raises an ObjectDisposedException. Now is normal operation this should not happen, but if for some reason it did, I would like to be able to handle the exception…
GazTheDestroyer
  • 20,722
  • 9
  • 70
  • 103
0
votes
1 answer

skipping Rows in a CSV file to a certain word C#

I am new to C# coding and I have really tried to find an answer in any forum. I am using CSVHelper to read a CSV file and I want to skip a certain number of lines from the beginning of the file to a certain word. Now my code gives the following…
xKara
  • 5
  • 3