Click here to Skip to main content
15,889,992 members
Home / Discussions / C#
   

C#

 
AnswerRe: Graphs in C# - Windows application Pin
Ravi Bhavnani24-May-10 14:42
professionalRavi Bhavnani24-May-10 14:42 
Questiongeting error message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." for code given below its aaper after end of function Pin
MS_TJ23-May-10 20:31
MS_TJ23-May-10 20:31 
AnswerRe: geting error message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." for code given below its aaper after end of function Pin
Dave Kreskowiak24-May-10 4:30
mveDave Kreskowiak24-May-10 4:30 
AnswerRe: geting error message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." for code given below its aaper after end of function Pin
Bernhard Hiller25-May-10 3:58
Bernhard Hiller25-May-10 3:58 
GeneralRe: geting error message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." for code given below its aaper after end of function Pin
MS_TJ25-May-10 6:43
MS_TJ25-May-10 6:43 
QuestionCan not open 'User Management' in the request database. Login failed. Pin
Make Up Forever23-May-10 20:03
Make Up Forever23-May-10 20:03 
AnswerRe: Can not open 'User Management' in the request database. Login failed. Pin
Mycroft Holmes23-May-10 23:05
professionalMycroft Holmes23-May-10 23:05 
QuestionSystem.ObjectDisposedException: Cannot access a disposed object. Pin
Jacob Dixon23-May-10 18:17
Jacob Dixon23-May-10 18:17 
I thought I had this down from asking this question before but I'm having issues with this once again.

What I am trying to do is load a picture from a database using the IDataReader (so I can read it byte by byte). Now I have this function in another class with events. So I have a ProgressChanged event and a Finished Event. Before calling these events I check if they are null and it still gives me this error

[5/23/2010 10:58:31 PM LoadPicture]: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'frmViewAsset'.
   at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
   at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
   at System.Windows.Forms.Control.Invoke(Delegate method)
   at AssetMgmt.frmViewAsset.p_ProgressChanged(Int32 current, Int32 max, String c, String t) in C:\Applications\Windows Applications\AssetMgmt\AssetMgmt\frmViewAsset.cs:line 388
   at AssetMgmt.LoadPicture.Load() in C:\Applications\Windows Applications\AssetMgmt\AssetMgmt\Operations\LoadPicture.cs:line 74


Now first you probably want to know what is line 388 on frmViewasset (this is the parent form). The code below is the event in the parent form.. the action it takes when the event is called from the LoadPicture class. The thing is I am "dispoing" of this event on the FormClosing and it still isn't working right.. givingme that error

       private void p_ProgressChanged(int current, int max, string c, string t)
        {
            if (!this.IsDisposed)
            {
                Invoke((Action)(() =>
                {
                    pbPicture.Maximum = max;
                    pbPicture.Value = current;

                    lbPicProgress.Text = string.Format("{0}MB / {1}MB", c, t);
                }));
            }
        }

LoadPicture lp;
        private void frmViewAsset_Load(object sender, EventArgs e)
        {
            lp = new LoadPicture(AssetID);
            lp.ProgressChanged += new LoadPicture.ProgressDelegate(p_ProgressChanged);
            lp.Finished += new LoadPicture.FinishedDelegate(p_Finished);

                t4 = new Thread(new ThreadStart(PopulatePicture));
                t4.Start();
       }

       private void PopulatePicture()
       {
          lp.Load();
       }
       private void frmViewAsset_FormClosing(object sender, FormClosingEventArgs e)
        {
            lp.Stop();
            lp.Dispose();
        }


So basicaly when the form loads it creates another thread that calls the lp.Load(). This begins the SQL Connection and reads byte by byte (or every 1024 bytes). Each time it loops it calls:

if (ProgressChanged != null)
ProgressChanged(blahblahblah);


So how come i'm c alilng my lp.Dispose() (which sets ProgressChanged = null) i still get this error when the user exits? I just can't figure it out
AnswerRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn23-May-10 19:02
sitebuilderLuc Pattyn23-May-10 19:02 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Jacob Dixon24-May-10 2:44
Jacob Dixon24-May-10 2:44 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 4:25
sitebuilderLuc Pattyn24-May-10 4:25 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Jacob Dixon24-May-10 5:01
Jacob Dixon24-May-10 5:01 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 5:06
sitebuilderLuc Pattyn24-May-10 5:06 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. [modified] Pin
Jacob Dixon24-May-10 5:26
Jacob Dixon24-May-10 5:26 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 6:23
sitebuilderLuc Pattyn24-May-10 6:23 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Jacob Dixon24-May-10 6:41
Jacob Dixon24-May-10 6:41 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 6:54
sitebuilderLuc Pattyn24-May-10 6:54 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Jacob Dixon24-May-10 7:13
Jacob Dixon24-May-10 7:13 
GeneralRe: System.ObjectDisposedException: Cannot access a disposed object. Pin
Luc Pattyn24-May-10 7:27
sitebuilderLuc Pattyn24-May-10 7:27 
Questiontype object Pin
tek 200923-May-10 10:32
tek 200923-May-10 10:32 
AnswerRe: type object Pin
Pete O'Hanlon23-May-10 10:46
mvePete O'Hanlon23-May-10 10:46 
AnswerRe: type object Pin
tek 200923-May-10 12:28
tek 200923-May-10 12:28 
QuestionOutput type of Class Library cannot be started directly Pin
tan_chin23-May-10 9:33
tan_chin23-May-10 9:33 
AnswerRe: Output type of Class Library cannot be started directly Pin
#realJSOP23-May-10 9:58
mve#realJSOP23-May-10 9:58 
GeneralRe: Output type of Class Library cannot be started directly Pin
tan_chin23-May-10 10:28
tan_chin23-May-10 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.