Thanks Bill - I am reading it now. (Is there a way to get an advert-free print or PDF save of those pages :-( ?)
I thought this was a reasonable discussion (but a little different than I want to achieve) - http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic62 109.aspx _____ Ian Thomas Victoria Park, Western Australia _____ From: [email protected] [mailto:[email protected]] On Behalf Of Bill McCarthy Sent: Friday, December 30, 2011 11:03 AM To: ozDotNet Subject: RE: Switching between single- and multiple-instance (WinForms) http://visualstudiomagazine.com/articles/2007/11/01/simplify-application-ins tancing.aspx?m=1 _____ From: Ian Thomas Sent: 30/12/2011 1:44 PM To: 'ozDotNet' Subject: RE: Switching between single- and multiple-instance (WinForms) Hi there Bill Almost every C# solution (to my stated scenario, and to writing a singleton, as well - or so it seems) uses a mutex. (In both C# and VB) there are several variants of code for recognizing a second instance, relying on Remoting ChannelServices. Maybe that is the insecurity issue that you are remembering? WPF + WCF is probably less ambiguous? _____ Ian Thomas Victoria Park, Western Australia _____ From: [email protected] [mailto:[email protected]] On Behalf Of Bill McCarthy Sent: Friday, December 30, 2011 8:00 AM To: ozDotNet Subject: RE: Switching between single- and multiple-instance (WinForms) Hi Ian, I think I wrote about this many years ago. Although the VB framework is easy to use, it can have some security issues, or at least did in its first incarnation as it uses a tempting channel to pass arguements. Usually this isn't an issue, but I do seem to recsllsome anti virus product would block that. In days of old you would create s mutex and probably use a custom window message or as I think I did, use named pipes _____ From: Ian Thomas Sent: 30/12/2011 2:02 AM To: 'ozDotNet' Subject: RE: Switching between single- and multiple-instance (WinForms) 'My' is available throughout the Framework. The way that VB does it is to auto-generate this (in Application.Designer.vb) - Namespace My 'NOTE: This file is auto-generated; do not modify it directly. To make changes, ' or if you encounter build errors in this file, go to the Project Designer ' (go to Project Properties or double-click the My Project node in ' Solution Explorer), and make changes on the Application tab. ' Partial Friend Class MyApplication <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ Public Sub New() MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMo de.Windows) Me.IsSingleInstance = true Me.EnableVisualStyles = false Me.SaveMySettingsOnExit = true Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormC loses End Sub <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ Protected Overrides Sub OnCreateMainForm() Me.MainForm = Global.iViewHelper.Form1 End Sub End Class End Namespace - and a dummy namespace My (in ApplicationEvents.vb) points to useful events - Namespace My ' The following events are available for MyApplication: ' Startup: Raised when the application starts, before the startup form is created. ' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally. ' UnhandledException: Raised if the application encounters an unhandled exception. ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. Partial Friend Class MyApplication End Class End Namespace So, I can tweak .IsSingleInstance and .StartupNextInstance appropriately via my configuration routines and some saved Settings; I'm just asking if there are other methods, and what the pros and cons might be. And - WinForms, not WPF (as the subject says). _____ Ian Thomas Victoria Park, Western Australia _____ From: [email protected] [mailto:[email protected]] On Behalf Of Ian Thomas Sent: Thursday, December 29, 2011 9:48 PM To: [email protected] Subject: Switching between single- and multiple-instance (WinForms) Visual Basic projects can be very easily made single instance (Make Single Instance Application property for the project), but I'd like a simple way to change single instance behaviour to multiple-instance (in the same way that many text editors allow it as a configuration - eg, TextPad). What is recommended? (either language) _____ Ian Thomas Victoria Park, Western Australia
