Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

WinForm Single Instance App errors out with AccessViolationException

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J. Clay - 17 Jul 2006 23:21 GMT
I have a couple of windows form applications that I am wanting to integrate
and have been playing around with the Single Instance Application setting.
I have tried this with my own app and the sample SingleInstance05 that I got
from MSDN.  I can run it, but if I go to a cmd console and go to the bin
directory and try and run the app again to trigger the SingleInstance
functionality, I get a System.AccessViolationException of

{"Attempted to read or write protected memory. This is often an indication
that other memory is corrupt."}

The stackTrace is as follows:

  at
System.Net.UnsafeNclNativeMethods.OSSOCK.WSAGetOverlappedResult(SafeCloseSocket
socketHandle, IntPtr overlapped, UInt32& bytesTransferred, Boolean wait,
IntPtr ignored)
  at
System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
  at
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Any suggestions?

TIA,
J. Clay
Linda Liu [MSFT] - 18 Jul 2006 05:25 GMT
Hi J.Clay,

Thank you for posting.

I don't know what sample you are trying with your application. But I will
give you a sample code that makes use of the Mutex class in
System.Threading namespace.

using System.Threading;

public class Form1:Form
{
   private void Form1_Load(object sender, EventArgs e)
       {
           Boolean requestInitialOwnership = true;
           Boolean mutexWasCreated = false;

           Mutex mut = new Mutex(requestInitialOwnership,
"MSFMSGUI_MUTEX",out mutexWasCreated);
           if (!mutexWasCreated)
           {                
               this.Close();
           }
       }
}

Hope this helps.
If you have anything unclear, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

============================================================================
=============================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.

============================================================================
=============================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Linda Liu [MSFT] - 21 Jul 2006 04:08 GMT
Hi J. Clay,

I am closely monitoring the newsgroup and I am contacting you to check the
issue status.

If the problem is not resolved or you have anything unclear, please feel
free to post in the newsgroup and we will follow up.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.