originally posted by: tbag
I have successfully implemented the CAB and OAB together but I am having a small issue. I used the CAB SmartPart QuickStart as the pattern for creating my SmartPart application. This QuickStart utilizes a class called SmartPartApplication.cs to provide the
Main() function to serve as an entry point to the application. I modified the code in the Main method to implement the OAB functionality when my application starts.
public static void Main()
MainForm mainForm = new MainForm();
connectionManagementController = new ConnectionController(mainForm);
connectionManagementController = null;
if (connectionManagementController != null)
I used the OAB Connection Management QuickStart as the pattern to implement the OAB. The application properly detects the connection state. I created two menu items in my MainForm to toggle the connection state from Online to Offline, both work properly.
Here is my issue. When the application is first loaded the SmartPartApplication().Run() code starts my application and the ConnectionManagerConnectionStateChangedEvent event handler properly detects the connection state.
The ConnectionController class UpdateState method then executes to update the connection status in the MainForm. Then the MainForm UpdateState method executes to set the enabled status of my menu items that toggle the connection state and set the status bar
After the MainForm UpdateStatus method executes the constructor for the MainForm class fires again and the InitializeComponent method is called. When the InitializeComponent method is called again the value for my status bar label is set back to its default
Once the application is loaded, clicking the menu items I have created to toggle connection state properly toggle the enabled state of the menu items and update the status bar label.
The event handlers for the menu items mentioned above call the UpdateState method of the MainForm.
private void goOnlineToolStripMenuItem_Click(object sender, EventArgs e)
private void goOfflineToolStripMenuItem_Click(object sender, EventArgs e)
These event handlers work properly because the MainForm constructor is not called again when they execute and the InitializeComponent method is not called.
I am trying to determine the correct place to implement the code to make the OAB functionality work inside my application without calling the constructor of the MainForm twice when the application is loaded. Does anyone know why this constructor is being called
twice when the application is initially loaded? How can I work around this?