none
Outlook addin start slowly RRS feed

  • Question

  • I wrote a outlook add in by C#. Sometimes we found that outlook add in load slowly on customer machine especially when the network isn't in good condition. For example, if the customer is in the office, it seems no problem happens, but if the customer works at home, the problem always happens. Then I added some time tag in the code to see why the add in start so slowly. After that, I saw there is a method named FinishInitialization() in OutlookAddInBase, this method callback by OutlookAddInBase. Also there is a method named InitializeDataBindings, the callback time interval between these two methods is too long. Then I Google this problem. But I didn't find any useful info for OutlookAddInBase. Below is log I made in the add in. Could someone help this or someone can tell the callback method mechanism in OutlookAddInBase? I also list the code, but the code is auto generated by VSTO. Also is there some network related functions in OutlookAddInBase callback methods? Thanks in advance.

    Code: 
    **[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "10.0.0.0")] 
            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)] 
            protected override void FinishInitialization() { 
                this.InternalStartup(); 
                this.OnStartup(); 
            } 
            [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "10.0.0.0")]
            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
            protected override void InitializeDataBindings() {
                this.BeginInitialization();
                this.BindToData();
                this.EndInitialization();
            }****

    Log: 
    ERROR: InitializeDataBindings end 2013-09-25 12:22:59.650 
    ERROR: 9/25/2013 12:23:04 PM 
    ERROR: FinishInitialization start2013-09-25 12:23:04.650   

    • Moved by ThankfulHeart Saturday, September 28, 2013 7:09 AM C# Question in English
    • Moved by CoolDadTx Monday, September 30, 2013 2:33 PM Office related
    Thursday, September 26, 2013 11:17 AM

All replies

  • Does anyone has any thoughts on this issue?
    Monday, September 30, 2013 8:34 AM
  • Can you show your code? I think what you have shown is the autogenerated code.

    Paul Linton

    Monday, September 30, 2013 11:04 AM
  • Yes, but the call back time interval is too long between these methods. I didn't change any code for the auto generated code. I mean call back time interval between method InitializeDataBindings and method FinishInitialization is too long. From the log I wrote, you can see that the interval is 5 seconds. I just want to know the Mechanism for OutlookAddInBase.

    Log: 
    ERROR: InitializeDataBindings end 2013-09-25 12:22:59.650 
    ERROR: 9/25/2013 12:23:04 PM 
    ERROR: FinishInitialization start2013-09-25 12:23:04.650 

    Tuesday, October 8, 2013 5:58 AM
  • I don't know what the flow of events is but have you  instrumented your own code?  Can you log constructor calls and method calls of your code in the same way that you are logging calls to the MS code?

    If you uninstall your AddIn does the delay go away?


    Paul Linton

    Tuesday, October 8, 2013 6:26 AM
  • Yes, I only add some code in method ThisAddIn_Startup.

    This is the code:

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        try
        {
            Logging.LogError("ThisAddIn_Startup start" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            CreateAppDataOntheUsers();
            Logging.LogError("CreateAppDataOntheUsers " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            LoadSettings settings = new LoadSettings();
            settings.LoadSettingsFromXML();
            Logging.LogError("LoadSettingsFromXML " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            Utils.InitializeSharedData();
            Logging.LogError("InitializeSharedData " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            Logging.InitializeLogging();
            app = this.Application;

            Logging.LogError("ThisAddIn_Startup end" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
        }
        catch (Exception ex)
        {
            Logging.LogError("Startup error", ex);
            MessageBox.Show(ex.Message + "\n Please Contact your System Administrator.");
        }

    }

    private void InternalStartup()
    {
        this.Startup += new System.EventHandler(ThisAddIn_Startup);

        this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);

    }

    But the method ThisAddIn_Startup only cause several miliseconds to run.

    From the logs I made, I can say that the system call InitializeDataBindings first, then after 5 seconds, the outlook system call the method FinishInitialization. I just don't know what outlook did in that 5 seconds and why it is so slowly.

    If I install my add-in, the outlook start very quickly.

    Wednesday, October 9, 2013 6:17 AM
  • Does the AddIn have a constructor?  When does it run?

    Does ThisAddIn_Startup run before or after InitializeDataBindings?  FinishInitialization?


    Paul Linton

    Wednesday, October 9, 2013 9:07 AM
  • VSTO addins handle the calls from Extensibility to initialize the addin. They load the addin into an isolated AppDomain, start the VSTO runtime, any data links and so on, and then fire the ThisAddIn_Startup() event that you handle.

    You cannot change or alter the startup code in any way, shape or form. It's already been optimized as much as possible by the VSTO team.

    Are you actually setting or using any data binding in your code?

    It's possible that by getting closer to the metal and using a shared addin architecture that you might speed things up a bit by directly handling the Extensibility events, but you still need to use a shim to load your addin into an isolated AppDomain, so you probably won't see much speedup if any.

    Bear in mind also that if your code is the first to start the version of the Framework that you reference that it will have to be started before your addin can run too.

     


    Ken Slovak MVP - Outlook

    Wednesday, October 9, 2013 2:53 PM
    Moderator
  • This is BindToData function, I didn't change anything. So I don't think we use some data binding related things. Really don't know why it starts up slowly.

            ///
            [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "10.0.0.0")]
            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
            private void BindToData() {
            }

    Saturday, October 12, 2013 10:28 AM
  • ThisAddIn_Startup run after InitializeDataBindings and FinishInitialization.
    Saturday, October 12, 2013 10:29 AM
  • This is the addin constructor.

            ///
            [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
            public ThisAddIn(global::Microsoft.Office.Tools.Outlook.Factory factory, global::System.IServiceProvider serviceProvider) :
                    base(factory, serviceProvider, "AddIn", "ThisAddIn") {
                Globals.Factory = factory;
            }

    Saturday, October 12, 2013 10:29 AM