C# Can';t调试Outlook的应用程序级外接程序
这是我第一次使用.NET为Outlook创建应用程序级外接程序。通过使用教程,我写下了一些代码,并成功地构建了它,但我无法调试代码。调试时,会显示一个警告框,提示: 无法运行或调试此项目,因为未安装所需版本的Microsoft应用程序 我正在使用Visual Studio 2010和MS Office 2007。为了调试代码,我应该做什么?我可以对代码进行任何更改以便调试它吗 这是密码C# Can';t调试Outlook的应用程序级外接程序,c#,outlook,vsto,ms-office,outlook-addin,C#,Outlook,Vsto,Ms Office,Outlook Addin,这是我第一次使用.NET为Outlook创建应用程序级外接程序。通过使用教程,我写下了一些代码,并成功地构建了它,但我无法调试代码。调试时,会显示一个警告框,提示: 无法运行或调试此项目,因为未安装所需版本的Microsoft应用程序 我正在使用Visual Studio 2010和MS Office 2007。为了调试代码,我应该做什么?我可以对代码进行任何更改以便调试它吗 这是密码 using System; using System.Collections.Generic; using S
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;
namespace OutlookAddIn1
{
public partial class ThisAddIn
{
Outlook.Inspectors inspectors;
event InspectorsEvents_NewInspectorEventHandler NewInspector;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
inspectors = this.Application.Inspectors;
inspectors.NewInspector +=
new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
if (mailItem != null)
{
if (mailItem.EntryID == null)
{
mailItem.Subject = "This text was added by using code";
mailItem.Body = "This text was added by using code";
}
}
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Xml.Linq;
使用Outlook=Microsoft.Office.Interop.Outlook;
使用Office=Microsoft.Office.Core;
使用Microsoft.Office.Interop.Outlook;
命名空间了望AddIn1
{
公共部分类ThisAddIn
{
展望.视察员;
事件检查器Events_NewInspector或Venthandler NewInspector;
私有void ThisAddIn_启动(对象发送方,System.EventArgs e)
{
检查员=this.Application.inspectors;
检查员,新检查员+=
新的Microsoft.Office.Interop.Outlook.InspectorEvents\u NewInspector或Venthandler(Inspectors\u NewInspector);
}
私有void ThisAddIn_关闭(对象发送方,System.EventArgs e)
{
}
无效检查器\u新检查器(Microsoft.Office.Interop.Outlook.Inspector)
{
Outlook.MailItem MailItem=Inspector.CurrentItem作为Outlook.MailItem;
if(mailItem!=null)
{
如果(mailItem.EntryID==null)
{
mailItem.Subject=“此文本是使用代码添加的”;
mailItem.Body=“此文本是使用代码添加的”;
}
}
}
#区域VSTO生成的代码
///
///设计器支持所需的方法-不修改
///此方法的内容与代码编辑器一起使用。
///
私有void InternalStartup()
{
this.Startup+=new System.EventHandler(ThisAddIn\u启动);
this.Shutdown+=new System.EventHandler(ThisAddIn\u Shutdown);
}
#端区
}
}
问题不在于您的代码,而是您的项目文件配置错误,以及您安装了哪个MS Office版本。看
对于MS Office 2007,您的项目文件DebugInfoExeName
应该是:
DebugInfoExeName=“#Software\Microsoft\Office\12.0\Outlook\InstallRoot\Path#Outlook.exe”
对于MS Office 2016,版本号为“16.0”。
Office Version | Version Number
---------------+-----------------
2007 | 12.0
2010 | 14.0
2013 | 15.0
2016 | 16.0