Click here to Skip to main content
16,012,116 members
Home / Discussions / C#
   

C#

 
GeneralRe: Class Not Registered Error (HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) Pin
Dave Kreskowiak4-Mar-10 6:54
mveDave Kreskowiak4-Mar-10 6:54 
GeneralRe: Class Not Registered Error (HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) Pin
Clifford Anup4-Mar-10 7:54
Clifford Anup4-Mar-10 7:54 
GeneralRe: Class Not Registered Error (HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) Pin
Dave Kreskowiak4-Mar-10 8:10
mveDave Kreskowiak4-Mar-10 8:10 
GeneralRe: Class Not Registered Error (HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) Pin
Clifford Anup4-Mar-10 8:25
Clifford Anup4-Mar-10 8:25 
GeneralRe: Class Not Registered Error (HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) Pin
Dave Kreskowiak4-Mar-10 9:05
mveDave Kreskowiak4-Mar-10 9:05 
QuestionC# Code example for adding File Attachments (when using Zetafax) Pin
But_Im_a_Lady4-Mar-10 3:35
But_Im_a_Lady4-Mar-10 3:35 
QuestionDetect if Application.Restart Fails. Pin
kevinnicol4-Mar-10 3:26
kevinnicol4-Mar-10 3:26 
AnswerRe: Detect if Application.Restart Fails. Pin
Alan N4-Mar-10 8:09
Alan N4-Mar-10 8:09 
Is the existing instance able to continue reliably once the option has been changed? If so it may be better to prompt the user to choose between "Restart now" and "I'll do it myself later" rather than just forcing the restart upon them.

Once Restart has been called it does look like the the second instance can't be stopped. However you can arrange for it to shutdown without creating any windows, i.e. create a so called single instance application.

The basic code is this (well one way of doing it)
static class Program {
  const String UniqueIdentifier = "{9E6F0AC4-B9A1-45QX-A8CF-72F04E6BDE8F}";
  static Boolean firstInstance;
  static Mutex mutex = new Mutex(true, UniqueIdentifier, out firstInstance);
  [STAThread]
  static void Main() {
    if (firstInstance) {
      Application.Run(new Form1());
    } else {
      MessageBox.Show("Already running");
    }
  }
}


The first instance creates and takes ownership of the mutex. Subsequent instances open the existing mutex and firstInstance is false.

Alan.
GeneralRe: Detect if Application.Restart Fails. Pin
kevinnicol4-Mar-10 8:17
kevinnicol4-Mar-10 8:17 
GeneralRe: Detect if Application.Restart Fails. [modified] Pin
Alan N4-Mar-10 13:19
Alan N4-Mar-10 13:19 
QuestionMy service must run my form Pin
Andy_R4-Mar-10 2:37
Andy_R4-Mar-10 2:37 
AnswerRe: My service must run my form Pin
Gonzoox4-Mar-10 3:35
Gonzoox4-Mar-10 3:35 
GeneralRe: My service must run my form Pin
Andy_R4-Mar-10 3:42
Andy_R4-Mar-10 3:42 
GeneralRe: My service must run my form Pin
Andy_R5-Mar-10 2:08
Andy_R5-Mar-10 2:08 
GeneralRe: My service must run my form Pin
Andy_R5-Mar-10 3:10
Andy_R5-Mar-10 3:10 
Questionparameter count mismatch listBox. Pin
arsendem4-Mar-10 2:30
arsendem4-Mar-10 2:30 
AnswerRe: parameter count mismatch listBox. Pin
Not Active4-Mar-10 3:04
mentorNot Active4-Mar-10 3:04 
AnswerMessage Closed Pin
4-Mar-10 3:05
stancrm4-Mar-10 3:05 
GeneralRe: parameter count mismatch listBox. Pin
arsendem4-Mar-10 3:20
arsendem4-Mar-10 3:20 
Questionappend to excel file c# !! Pin
noamtzu004-Mar-10 1:42
noamtzu004-Mar-10 1:42 
AnswerRe: append to excel file c# !! Pin
Not Active4-Mar-10 1:57
mentorNot Active4-Mar-10 1:57 
GeneralI know this, but more comfortable working with ..... Pin
noamtzu004-Mar-10 2:41
noamtzu004-Mar-10 2:41 
GeneralRe: I know this, but more comfortable working with ..... Pin
Not Active4-Mar-10 2:59
mentorNot Active4-Mar-10 2:59 
GeneralRe: I know this, but more comfortable working with ..... Pin
noamtzu004-Mar-10 7:16
noamtzu004-Mar-10 7:16 
GeneralRe: I know this, but more comfortable working with ..... Pin
Mirko19804-Mar-10 3:15
Mirko19804-Mar-10 3:15 

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.