【问题标题】:WPF Window within VSTO outlook AddIn projectVSTO Outlook 插件项目中的 WPF 窗口
【发布时间】:2016-11-15 22:03:36
【问题描述】:

我创建了一个简单的 VSTO Outlook 插件项目,只是想在 Outlook 中拥有一个按钮的功能,它可以执行一个显示 WPF 窗口的 VBA 代码,

当我运行这个带有 WinForms 的 Com 插件项目时,它通过 Visual Studio 的调试模式和执行 Outlook 并单击运行 VBA 代码的按钮来执行 com 插件,但是当我将其更改为 WPF Window 它在 Visual Studio 中运行良好,我的意思是我运行了该项目,它执行了 Outlook,然后我选择了一封电子邮件并单击了按钮,该按钮执行了 com 插件并显示了 WPF 表单,但是一旦我通过运行 Outlook(没有 VS 环境)尝试此操作,无论我尝试过什么,它都会一遍又一遍地解决此错误。

我在以下链接中附加了outlookAddin 项目和VBA 代码:

https://www.dropbox.com/sh/sbd9upmxthrigha/AACjx2jfmVZKFcqwQfX6SjCJa?dl=0

如果我从现有(运行 WPF 表单)替换 TCMSCom.cs 文件中的此方法

    public string OpenConfirmationWizard()
    {

        // run WPF

        TCMSWizard ui = new TCMSWizard();
        ui.ShowDialog();

        // run winforms

        //UserControl1 ui = new UserControl1();
        //ui.ShowDialog();
        return string.Empty;
    }

为此它会运行一个winforms

    public string OpenConfirmationWizard()
    {
        //TCMSWizard ui = new TCMSWizard();
        //ui.ShowDialog();

        UserControl1 ui = new UserControl1();
        ui.ShowDialog();
        return string.Empty;
    }

链中第一个异常的堆栈跟踪: 在 System.Windows.Window..ctor() 在 C:\Users\eranm\Documents\TFS\PI-HF_TCMSCOMAddIn\Features\TCMSCOMAddIn_Phase1\TCMSCOMAddIn\TCMSWizard.xaml.cs:line 23 中的 TCMSCOMAddIn.TCMSWizard..ctor() 在 C:\Users\eranm\Documents\TFS\PI-HF_TCMSCOMAddIn\Features\TCMSCOMAddIn_Phase1\TCMSCOMAddIn\TCMSCom.cs:line 22 中的 TCMSCOMAddIn.TCMSCom.OpenConfirmationWizard() 处

链中最后一个异常的堆栈跟踪: 在 System.Uri.CreateThis(字符串 uri,布尔值 dontEscape,UriKind uriKind) 在 MS.Internal.FontCache.Util..cctor()

链中的异常消息如下:

“'system.windows.window' 的类型初始化器抛出异常”

“'System.Windows.FrameworkElement' 的类型初始化程序引发了异常。”

“'System.Windows.Documents.TextElement' 的类型初始化程序引发了异常。”

“'MS.Internal.FontCache.Util' 的类型初始化程序引发了异常。”

“无效的 URI:无法确定 URI 的格式。”

感谢您帮助解决这个问题

非常感谢,

伊兰

【问题讨论】:

  • 如果您可以发布您的类型初始化异常的StackTraceInnerException,这将非常有帮助。
  • 嗨,我添加了第一个和最后一个异常的堆栈跟踪以及链中所有异常的消息。
  • 检查answer here并检查Microsoft的注册表项mentioned here

标签: c# wpf winforms vsto add-in


【解决方案1】:

好的,错误已修复,

问题是注册表环境中的路径变量设置为超过 2048 个字符。

【讨论】:

    猜你喜欢
    • 2022-07-22
    • 1970-01-01
    • 2016-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多