ptenter

Hi,

I am developing a C# WinForms application using Visusal Studio 2005 Professional. I'm opening a sub-form form3 in another sub-form form1 in separate thread by following way:

Thread newTh1;
newTh1 = new Thread(new ThreadStart
(DisplayForm));
newTh1.SetApartmentState(ApartmentState
.STA);
newTh1.Start();

private void
DisplayForm()
{
frmForm3 fm3 = new frmForm2()
;
fm3.Owner = this
;
fm3.ShowDialog();
}

Form3 contains ShockwaveFlashObject.

If I run project through VS, it will display error Application.vshotst.exe has encountered a problem.

If I directly run application file, it will open form3 but it will display two different error on following actions (only incase if I open form3):

1) Attempted to read/write protected memory when closing application (clicking on X sign on application) followed by Application encountered with a problem and need to close

2) Application encountered with a problem and need to close when closing application using Exit menu.

Note: I'm opening form2 in form1 using same threading code. form3 is newly added.

Am I following right way to open unmanaged code with threading

Please help me out to solve the error!

Thanks



Re: Windows Forms General Attempted to read/write protected memory OR vshotst.exe has encountered a problem

TilakGopi

The message you are replying to:
Posted By: ptenter on 03-20-2007 12:35 PM UTC
Subject: Attempted to read/write protected memory OR vshotst.exe has encountered a problem
Message:

Hi,

I am developing a C# WinForms application using Visusal Studio 2005 Professional. I'm opening a sub-form form3 in another sub-form form1 in separate thread by following way:

Thread newTh1;
newTh1 = new Thread(new ThreadStart
(DisplayForm));
newTh1.SetApartmentState(ApartmentState
.STA);
newTh1.Start();

private void
DisplayForm()
{
frmForm3 fm3 = new frmForm2()
; // Is this frmForm3 frm3 = new frmForm3() or new frmForm2();
fm3.Owner = this
;
fm3.ShowDialog();
}

==================================================

Thanx,

Ch.T.Gopi Kumar.






Re: Windows Forms General Attempted to read/write protected memory OR vshotst.exe has encountered a problem

ptenter

Just a typing mistake. Its new frmForm3()

Thanks





Re: Windows Forms General Attempted to read/write protected memory OR vshotst.exe has encountered a problem

TilakGopi

Hi,

Is ur problem solved Still there

If problem is there, post the code , why because , i have tried ur sample with a single form.I didn't get any error.That's why i wanna see ur code.

Thanx,

Ch.T.Gopi Kumar.






Re: Windows Forms General Attempted to read/write protected memory OR vshotst.exe has encountered a problem

Ting Wang - MSFT

This is an access violation error. I am quite sure it is caused by some external components (maybe the ShockwaveFlashObject). .Net generated exceptions will usually result in the following message:

Unhandled exception has occurred in your application... Exception of type "..." was thrown.

To isolate the problem you can try removing any third party components from Form3. Do we still get the error in that way

By the way, why do you want to create a seperate thread to show the new form






Re: Windows Forms General Attempted to read/write protected memory OR vshotst.exe has encountered a problem

ptenter

I got solution in another thread.

Ting Wang - MSFT wrote:

This is an access violation error. I am quite sure it is caused by some external components (maybe the ShockwaveFlashObject). .Net generated exceptions will usually result in the following message:

Unhandled exception has occurred in your application... Exception of type "..." was thrown.

To isolate the problem you can try removing any third party components from Form3. Do we still get the error in that way

By the way, why do you want to create a seperate thread to show the new form





Re: Windows Forms General Attempted to read/write protected memory OR vshotst.exe has encountered a problem

Ting Wang - MSFT

Thanks. I see the other thread at http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1373780&SiteID=1

I am quoting it here so that other people looking at this thread may see it more easily.