Questions tagged [objectdisposedexception]

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

190 questions
0
votes
1 answer

ObjectDisposedException in a client server application

I've received an assignment in my C# course to build a multi-client chat in WinForms using the TcpClient / TcpServer classes with the use of Serialization & Deserialization via BinaryFormatter. When I'm using the Disconnect method from the client…
0
votes
0 answers

Web service getting disposed before a method call

I'm getting a System.ObjectDisposedException with the following code: using (AdminServiceClient web Service = new AdminServiceClient) { webService.Open(); ... var jsonToReturn = new { ... data = addresses.Select(address…
LOL. NO.
  • 577
  • 1
  • 6
  • 33
0
votes
1 answer

How to solve "ObjectContext instance has been disposed and can no longer be used for operations that require a connection" for a strange situation

I know how to fix this problem, but, this error is appearing in a situation totally different to me. In my MVC Razor view I have the following code that will filter a list of the model, and bring to me a specific object based on the user logged on…
Dan
  • 1,518
  • 5
  • 20
  • 48
0
votes
2 answers

vb.net cannot access a disposed object when opening form

I have a program that we use to run different reports. Based on the menu option chosen, I open the same form that lists the reports based on the menu option. (There are also different options and functionalities in the program, not just one…
Gerben
  • 117
  • 1
  • 2
  • 10
0
votes
2 answers

Should I heed this superficially nonsensical Code Analysis warning?

When I select Analyze > RUn Code Analysis on Solution in Visual Studio 2013, I get, "CA2202 Do not dispose objects multiple times Object 'fs' can be disposed more than once in method 'RoboReporterSQL.SaveReportDataToDB(string, string)'. To avoid…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
0
votes
1 answer

ObjectDisposedException when using IMessageFilter

I recently had a situation where I had a form that I was intercepting and processing messages for. Everything worked fine the first time the form was opened, but after closing and opening again, I would get an ObjectDisposedException. I finally…
0
votes
0 answers

Cannot access a disposed object with Constructor injection

We get a System.ObjectDisposedException: Cannot access a disposed object exception in the 'DeactivateUser' method shown below. What's wrong with this code? public class HomeController { private readonly IUserService _userService; public…
user2893547
  • 135
  • 1
  • 9
0
votes
1 answer

Entityframework ObjectContext instance has been disposed in certain location

I'm getting the exception: "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection." Only when I try to add the object or some properties of that object to @Html.ActionLink. I have reviewed…
0
votes
2 answers

Replace all exceptions from a class

Is there a way in C# to replace all the ObjectDisposedException thrown by an instance of a NetworkStresm with MyException? The purpose of this is that I want to read and write the stream while other threads may dispose it. And that's just fine -…
Ella Sharakanski
  • 2,683
  • 3
  • 27
  • 47
0
votes
1 answer

C# -- this.Show(),Close() and Hide() not working or crashing

Today, I'm using a lot these functions but I have already found several problems about them. My program is so structured: This is Form 1: public partial class Form1 : Form { public Form1() { InitializeComponent(); ... …
Ricks23
  • 11
  • 1
  • 2
0
votes
1 answer

ObjectDisposedException when using extension method on RSAKeyValue

I was trying to write the following simple extension method for RSAKeyValue: public static class RSAKeyValueExtensions { public static string ToXmlString(this RSAKeyValue keyValue) { return keyValue.GetXml().OuterXml; …
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
0
votes
0 answers

Close thread while closing form

I do my first tries in c#. In my application a new Fom is created to show some measurements. i do this in a thread. on form closing i will exit the thread. sometimes it throws a ObjectDisposedException exception. i tried to handle it with a mutex.…
lalelu
  • 103
  • 9
0
votes
0 answers

C# Use database object after dataContext disposed

i want to store often loaded data from my database to my servers MemoryCache in my web application. Every time a class will access the cache and get the object there is a ObjectDisposedException exception on the references from the object. So i…
PX Roth
  • 139
  • 2
  • 16
0
votes
1 answer

ObjectDisposedException on Foreign entity

I'm quite a newbie with Linq to Sql, and I'm facing an issue regarding accessing a foreign entity. Here is the related DB : Table MyClass with two columns : Id, ProducerId Table Person with two columns : Id, Affix Here is my partial class : public…
Flash_Back
  • 565
  • 3
  • 8
  • 31
0
votes
1 answer

Accessing a disposed object (form) in C#?

I have two forms, once I double click a row on a dataGridView of one form, the other form opens up with information about that particular row. But after I close the second form and double click on another row in my dataGridView to open the same form…
Dave Howson
  • 156
  • 6
  • 14