none
Character duplication if add-in tries to access selection style when user is typing text RRS feed

  • Question

  • Hello!

    Our application is add-on for different editors. Some time ago we announced support for Office 2010/2013, but one issue prevents us from releasing add-in for Word: if add-in is enabled, Word sometimes duplicates typed characters.

    Proof video is here: http://www.youtube.com/watch?v=EmjHxMlgn6E

    We found that issue is reproducible if user is typing and at the same time add-in accesses Application.Selection.Style object.

    Steps to reproduce: Add following code to Word Add-in, generated by Visual Studio:

          
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
      _delayTimer = new System.Windows.Forms.Timer();
      _delayTimer.Interval = 1;
      _delayTimer.Tick += DelayTimerOnTick;
      _delayTimer.Enabled = true;
    }
    
    private void DelayTimerOnTick(object sender, EventArgs eventArgs)
    {
        _delayTimer.Stop();
        var sel = Globals.ThisAddIn.Application.Selection;
        sel.get_Style();
        Thread.Sleep(160);
        sel.get_Style();
        _delayTimer.Start();
    }
    		}

    Window messages in "character duplication" scenario are the same as for not duplicated: wm_keydown, wm_keyup, wm_char with no repeat.

    I doubt we will wait for patches or for new Office, so our question is - do we have a workaround? Maybe some undocumented flag or api call?

    Thanks
    Thursday, October 1, 2015 10:40 AM

Answers

All replies

  • Hi Nikolay Penn,

    As far as I know, there are several timers provide in .Net Framework. And the System.Windows.Forms.Timer is used in the Windows Form developing.

    As far as I test, when I used System.Timers.Timer, the issue was fixed. You can try to search the times in .Net as keywords to see the difference among them.

    Hope it is helpful.

    Regards & Fei 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 2, 2015 7:24 AM
    Moderator
  • Problem is not in timer, timer used just in reproduction purposes.

    In production code timers are not used

    Friday, October 2, 2015 2:45 PM
  • Hi Nikolay,

    Problem is not in timer, timer used just in reproduction purposes.

    In production code timers are not used

    Would you mind sharing a demo code without using timer to reproduce this issue? Since the issue was fixed if I use the System.Timers.Timer.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 6, 2015 6:55 AM
    Moderator
  • Issue is a bit tricky to reproduce and I can't publish productive code here. I will try to find another reproduction method, but can you in the meanwhile answer the simple question - why duplication at all happens?

    BTW: it's easily reproducible without add-ons at all: just type something and let somebody move mouse over style buttons.

    P.S. Possible reason is that some events (WindowSelectionChange at least) are fired inside the get_Style accessor.

    P.P.S. get_Style accessor is very rich and has noticeable side effects, it not just returns style of current paragraph. We found today that it moves the focus inside editor window. Quite strange for just accessor, right?

    Ah, and the difference between Windows Forms timer and System.Timers.Timer is execution thread: Windows Forms timer executes in Word thread, System.Timers.Timer - in special "timer" thread. There a lot of consequences, you should know them well. At least COM marshalling and absolutely another execution speed. Maybe because of that issue is not reproducible with another timer type.

    My opinion: there are races somewhere inside get_Style accessor. I'm just asking for qualified assistance in finding a workaround.

    Tuesday, October 6, 2015 1:42 PM
  • Hi Nikolay,

    >>BTW: it's easily reproducible without add-ons at all: just type something and let somebody move mouse over style buttons. <<

    I am failed to reproduce this issue in Word 2013. What's version of Word are you using? And can you reproduce this issue on other computers?

    >>My opinion: there are races somewhere inside get_Style accessor. I'm just asking for qualified assistance in finding a workaround.<<

    If the issue is urgent, I suggest that you contacting Microsoft support to raise an incident so that our engineer could work closely with him to identify the root cause and resolve this issue as soon as possible.

    If the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged.

    Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 7, 2015 7:20 AM
    Moderator
  • >>I am failed to reproduce this issue in Word 2013. What's version of Word are you using? And can you reproduce this issue on other computers?

    We were able to reproduce this issue on all Word versions from 2007 to 2013.

    Please, see reproduction without Add-Ins on Word 2013:

    http://www.youtube.com/watch?v=_MIUDnvFNRA

    Could be also important information that Word 2013 freezes very frequently immediately after such "experiment". We tried to debug it, but, unfortunately, Office symbols are not available on Microsoft Symbols Servers, so I only can provide a dump, if it will be interesting to anybody.

    >> I suggest that you contacting Microsoft support to raise an incident

    Can you provide us direct contacts to responsible developer? We are ready to raise incident as a bug.


    Wednesday, October 7, 2015 8:03 AM
  • Hi Nikolay,

    Thanks for the detail information. I am also could reproduce this issue too.

    >>Can you provide us direct contacts to responsible developer? We are ready to raise incident as a bug.<<

    Sorry, we have no channel to contact the Microsoft developer directly. However, we can submit the incident via link below:
    https://support.microsoft.com/en-us/getsupport?oaspworkflow=start_1.0.0.0&wf=0&wfName=productselection&gprid=16906&ccsid=635798834008592302

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Nikolay Penn Friday, October 9, 2015 10:27 AM
    Thursday, October 8, 2015 6:44 AM
    Moderator