GeckoFx60 与 Outlook 小数点混淆

问题描述

我正在 Outlook VSTO 解决方案中实施 GeckoFx60。 一旦我调用 xpcom.Initialize() 方法,Outlook 中的所有小数都会更改。

例如,提醒对话框建议将会议提醒推迟 5,00000000000 分钟。 此外,天气预报从 17 摄氏度变为 17,000 亿摄氏度。

使用 GeckoFX45 一切正常,但我需要 GeckoFx 60。

示例:

Example

重现该问题相当容易:

  • 打开 Visual Studio 2013
  • 新项目
  • Visual C# > Office/Sharepoint > Outlook 2013 加载项
  • 编辑 csproj 文件并将 DebugInfoExeName 从 Office\15.0\Outlook\installroot 更改为 Office\16.0\Outlook\installroot
  • 将项目目标框架更改为 .NET Framework 4.5
  • Nuget 包管理器 > 安装 geckofx-60 Windows 32 位
  • 更改 ThisAddIn_Startup
        [STAThread]
        private void ThisAddIn_Startup(object sender,System.EventArgs e)
        {
            xpcom.Initialize("Firefox");
        }

如果您启动 Outlook,小数位会更改。 Thread.CurrentThread.CurrentCulture 和 Thread.CurrentThread.CurrentUICulture 在调用 Initialize 前后还是一样的。

即使是线程,也存在相同的问题:

        private void ThisAddIn_Startup(object sender,System.EventArgs e)
        {
            Thread thread = new Thread(init);
            thread.TrySetApartmentState(ApartmentState.STA);
            thread.Start();
        }

        private void init()
        {
            xpcom.Initialize("Firefox");

        }

解决方法

自我回答我的问题:) 我在这个主题上做了很多研究和测试。 我已经在 firefox-sdk 52 上尝试过 XulFx 并遇到了完全相同的问题。 微软和苹果有几个关于这个的话题; Apple iCloud 与 Microsoft Outlook 结合使用时也存在此问题。

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_outlook-mso_winother-mso_365hp/outlook-application-number-format/e8442cd7-4903-4317-b2b9-0fbf9c260cde https://answers.microsoft.com/en-us/msoffice/forum/msoffice_outlook-mso_windows8-mso_2013_release/outlook-2013-gives-12-decimals-after-the/517799f8-58bb-4d31-a32d-85ab20fb0286 https://social.technet.microsoft.com/Forums/office/en-US/765eef7e-3d86-4fdb-8e86-04342b882698/too-many-decimals-zeros-show-in-outlook-calender?forum=outlook https://discussions.apple.com/thread/6693701 https://discussions.apple.com/thread/8089708

我只是放弃并转而使用 Microsoft 的 WebView2 组件。 (https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms)