The exception that is thrown when an operation is performed on a disposed object.
Questions tagged [objectdisposedexception]
190 questions
0
votes
1 answer
Cannot access a disposed object in Delphi Prism
I am programming under Delphi Prism for Mono. I keep getting this error, "Cannot access a disposed object" after opening already opened and closed window form, even though the window form is declared within a class and instantiated in the…

ThN
- 3,235
- 3
- 57
- 115
0
votes
0 answers
System.ObjectDisposedException: Cannot access a closed Stream on HTTP POST/PUT in .NET Core 3.1
Upgraded my app from .NET Core 2.2 to .NET Core 3.1. On one of my api endpoints that creates/updates a record, via HTTP POST or PUT, I am getting following error:
System.ObjectDisposedException: Cannot access a closed Stream.
at…

Bmoe
- 888
- 1
- 15
- 37
0
votes
0 answers
System.ObjectDisposedException: 'Cannot access a disposed object
So I've been following a YouTube tutorial on how to recreate a school attendance/login system using C# and MySQL for Visual Studio, and when I try logging in with or without typing anything in the text boxes, I keep getting the error in the title.…

kiehuc
- 1
0
votes
1 answer
ObjectDisposedException thrown everytime a "User" (membership) object is updated
I am using asp.net mvc 3, entity framework with structure map for IoC.
I have my own custom membership provider.
I had the same kind of problem when I was injecting the dbcontext object and the membership instances using StructureMap so removed…

amythn04
- 388
- 2
- 11
0
votes
0 answers
c#.Net PowerShell Class
I'm trying to use a PowerShell object with a remote runspace.
The initial connection is established, the test returns back with the correct responses, all appears good. I then assign my powershell object some commands to run, and it pops up with the…

Ste
- 1
- 4
0
votes
1 answer
ObjectDisposedException trying implement DDD project
When I try to return my orderList as IQueryable, I get the following error:
"ObjectDisposedException: Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later…

Guto Barroso
- 131
- 1
- 12
0
votes
0 answers
How do I solve this error: 'Cannot access a disposed object. Object name: 'IncomeForm'.'?
What I'm trying to do is get user input from a form (IncomeForm) by using a textbox (TextBoxIncomePrice) and after pressing the button (ButtonConfirmIncome), the LabelIncome label in the form MainPage should change to the value input by the…

isidoros _
- 11
- 4
0
votes
1 answer
Why does setting Log on a DataContext cause an ObjectDisposedException?
This is my service class:
public class MyService
{
private readonly MyDataContext _db;
public MyService()
{
_db = new MyDataContext(GetConnectionString());
#if DEBUG
_db.Log = Console.Error;
#endif
}
public void Get(int id)
{
…

Brandon
- 68,708
- 30
- 194
- 223
0
votes
1 answer
How can I prevent my System.Timers.Timer from raising the Elapsed event after it got stopped?
I have the followig code:
using (FileStream sourceStream = sourceFile.Open())
{
using (FileStream targetStream = File.Create(targetFilePath))
{
using (Timer timer = new Timer(250))
{
timer.Elapsed += (sender, e)…

Flagbug
- 2,093
- 3
- 24
- 47
0
votes
0 answers
ObjectDisposedException thrown when using the WritableBitmap
I am trying to convert the rendered stream from RenderTargetBitmap to the writable bitmap. I used the below code in button click and convert the stream to bitmap. If continuously converting the bitmap means it throws an ObjectDisposedException.
Code…

Santhiya
- 191
- 2
- 14
0
votes
0 answers
How to avoid ObjectDisposedException when closing application
I have a problem replicated all over the application, but I think it could be managed the same way.
I have an IDisposable class in my Winforms application (it is a custom control derived from System.Windows.Forms.Label)
In that class, I have a timer…

jstuardo
- 3,901
- 14
- 61
- 136
0
votes
1 answer
MemoryStream throws System.ObjectDisposedException
I want to resize images for iOS so that I don't have to do it manually all the time. This should be done using WPF but it throws a ObjectDisposedException.
What it does is the user selects a csproj file and then an image which will be resized in 3…

MelloPs
- 135
- 11
0
votes
0 answers
After retargeting to .NET Core 2.1 getting new error System.ObjectDisposedException: Cannot access a disposed object
I've just successfully retargeted my Web API app from .NET Framework 4.7.1 to .NET Core 2.1. The application runs perfectly on my local machine.
After deploying it to an Azure app service the app starts up and looks healthy. However I log the…

08Dc91wk
- 4,254
- 8
- 34
- 67
0
votes
1 answer
ObjectDisposedException in ASP.NET Boilerplate manage services
I've decided to separate logic from RoleAppService to RoleService, because I need to use role methods in other app services. By separating logic I can avoid injecting endpoints to other endpoints (e.g. RoleAppService to UserAppService) and possible…

Plusce
- 117
- 2
- 14
0
votes
0 answers
DataGridView.BeginEdit() fails because DataGridViewTextBoxEditingControl is disposed
In the code below, I simply try to do a BeginEdit(False) in a DataGridView. Occasionally, this fails with:
System.ObjectDisposedException
HResult=0x80131622
Message=Cannot access a disposed object.
Object name:…

CeSinge
- 21
- 6