Questions tagged [objectdisposedexception]

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

190 questions
1
vote
1 answer

ObjectDisposedException even though I'm using .Include(), .ToList(), and everything else

My project is C# .NET, MVC 5, EF6. I'm getting an ObjectDisposedException on using an object in a view that has been gotten from the database. I've read probably EVERY similar question, but .Include() does NOT work; I'm thinking the problem…
levininja
  • 3,118
  • 5
  • 26
  • 41
1
vote
2 answers

Cannot access a disposed object on Program.cs Main method

I have a WinForm application with two different forms. If the first command line argument is "download", the Download form should appear. I get an ObjectDisposedException on the Application.Run(new Download(args)); line on the Main method of my…
disasterkid
  • 6,948
  • 25
  • 94
  • 179
1
vote
1 answer

Warning: Do not dispose objects multiple times

EDIT: This question is not a duplicate!, maybe is a frequent question the "what means this warning?" but is not a duplicate when I'm asking how to fix the warning in a specific code, and I can't by myself even knowing the significate of the warning.…
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
1
vote
1 answer

Strange SerialPort behavior crashes application

I observe some strange behavior when trying to access the SerialPort via .NET framework. What I do is loop over all available com ports, send a string, read the response and close the port. The purpose is to check on which port a device is…
Martin Booka Weser
  • 3,192
  • 5
  • 28
  • 41
1
vote
2 answers

ObjectDisposedException - running stopwatch in GUI thread

I have a stopwatch running in a different thread, that updates the GUI thread in a label to show as time goes by. When my program closes, it throws a ObjectDisposedException when I call this.Invoke(mydelegate); in the Form GUI to update the label…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
1
vote
0 answers

ObjectDisposedException when trying to run a form

I am a new C# programmer and I am trying to make a program to send an email containing the contents of a MSSQL table. The main program looks like this: using System; using System.Collections.Generic; using System.Linq; using…
Josh Coats
  • 19
  • 5
1
vote
1 answer

Linq force load entities with DefaultIfEmpty gives ObjectDisposedException

I have this linq: using (PlantContext context = ContextManager.GetPlantContext(plantId.PlantPath)) { results = (from p in context.Plants join subplant in context.Subplants on p.Id equals subplant.PlantId …
Paul
  • 193
  • 1
  • 11
1
vote
2 answers

Unit test throwing ObjectDisposedException with ObjectContext

I have unit tests where I am creating and seeding a SQLCE4 database prior to each test method. In the test method if I have a query like this: var maxGroupLevel = repository.Get().Max(g => g.Id); It will throw the exception…
user380689
  • 1,766
  • 4
  • 26
  • 39
1
vote
0 answers

Can't run 'ConnectionFactory.CreateConnection( )' in MonoTouch's RabbitMQ .NET Client DLL

I have ported RabbitMQ .NET client DLL to MonoTouch project (iOS Project), i can send message to RabbitMQ Server, but i can't receive any message and cause exception , now i post these code: bool _DoneFlag=false; QueueingBasicConsumer…
1
vote
2 answers

ObjectDisposed when closing multithreaded app

Possible Duplicate: How to stop BackgroundWorker on Form’s Closing event? **Regarding possible duplicate - BackgroundWorker methods are not applicable here. Below is my attempt to use AForge library to receive video from IP cameras. Each video…
1
vote
2 answers

"Cannot access a disposed object" when checking for IsDisposed and Disposing

When the application receives a call from the service, it opens a form for each call. The user must make his input in each window and the close it. In order to smooth the user's work I am trying to reactivate the window the user was working on when…
CristisS
  • 1,103
  • 1
  • 12
  • 31
1
vote
2 answers

How to check for disposed objects and throw ObjectDisposedException in methods if already disposed

I have a disposable class which implements IDisposalbe interface with disposable pattern. To maintain the constrains, I need to make sure that when the object has been disposed, any subsequent call to any public method throws…
1
vote
2 answers

TcpClient and NetworkStream dispose problem

I'm using this piece of code to process a connection to a server and read data from the client using(var client = _listener.EndAcceptTcpClient(ar)) { var clientStream = client.GetStream(); // Get the request message …
foliveira
  • 626
  • 1
  • 8
  • 15
0
votes
3 answers

Unhandled exception when opening then closing and once again opening a new form

I'm getting ObjectDisposedException was unhandled with message Cannot access a disposed object. This happens when initialize this child form at the beginning of my class by MyForm myForm = new MyForm(); and then adding some text to my text box of…
HelpNeeder
  • 6,383
  • 24
  • 91
  • 155
0
votes
1 answer

c# XNA Cannot access a disposed object. Object name: 'Texture2D'. But im not disposing it

Error: Cannot access a disposed object. Object name: 'Texture2D' Why is this happening! Nowhere in the whole of my code does it tell it to dispose! This is occuring on the LoadContent() in my XNA c# game. Code where i get this error, ive highlighted…