Search Results

Search found 2 results on 1 pages for 'user320781'.

Page 1/1 | 1 

  • ObjectDisposedException when .Show()'ing a form that shouldn't be disposed.

    - by user320781
    ive checked out some of the other questions and obviously the best solution is to prevent the behavior that causes this issue in the first place, but the problem is very intermittent, and very un-reproduceable. I basically have a main form, with sub forms. The sub forms are shown from menus and/or buttons from the main form like so: private void myToolStripMenuItem_Click(object sender, EventArgs e) { try { xDataForm.Show(); xDataForm.Activate(); } catch (ObjectDisposedException) { MessageBox.Show("ERROR 10103"); ErrorLogging newLogger = new ErrorLogging("10103"); Thread errorThread = new Thread(ErrorLogging.writeErrorToLog); errorThread.Start(); } } and the sub forms are actually in the main form(for better or worse. i would actually like to change this but would be a considerable amount of time to do so): public partial class FormMainScreen : Form { Form xDataForm = new xData(); ...(lots more here) public FormMainScreen(int pCount, string pName) { InitializeComponent(); ... } ... } The Dispose function for the sub form is modified so that, the 'close' and 'X' buttons actually hide the form so we dont have to re-create it every time. When the main screen closes, it sets a "flag" to 2, so the other forms know that it is actually ok to close; protected override void Dispose(bool disposing) { if (FormMainScreen.isExiting == 2) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } else { if (xData.ActiveForm != null) { xData.ActiveForm.Hide(); } } } So, the question is, why would this work over and over and over again flawlessly, but, literally, about every 1/1000 of the time, cause an exception, or rather, why is my form being disposed? I had a suspicion that the garbage collector was getting confused, because it occurs slightly more frequently after it has been running for many hours.

    Read the article

  • C# app that uses Excel Interop, easy switch between 2003 2007?

    - by user320781
    I have an app written that just does really basic I/O on a spreadsheet. Read in a bunch of cells, do some sorting, and dump the output back into another spreadsheet. Works great on my machine. I have Office 2003 installed. When it runs on someone elses machine with 2007, it bombs, presumably due to the different versions of the Interop assemblies. I was hoping someone knew a way to dynamically change which/where the assembly is loaded from depending on the office version (getting the office version is easy from the registry). Sifting thru the rest of the internet, i didnt see anything to indicate that was possible :( . I tried installing the 2007 PIAs, but when i try to add a reference, they dont show up and i have no idea where to browse for them (they arent in the c:\windows\assemblies\; maybe the install didnt work). Am I going to have to get a machine with 2007 installed to build on every time i need to make updates?

    Read the article

1