7

.NETを使用してOutlook用のアプリケーションレベルのアドインを作成するのはこれが初めてです。チュートリアルを使用して、いくつかのコードを書き留めて、正常にビルドされましたが、コードをデバッグできませんでした。デバッグ中、アラートボックスに次のように表示されます。

必要なバージョンのMicrosoftアプリケーションがインストールされていないため、このプロジェクトを実行またはデバッグできません。

VisualStudio2010MSOffice2007を使用しています。コードをデバッグするにはどうすればよいですか?デバッグできるようにコードに変更を加えることはできますか?

これがコードです

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
    }
}
4

1 に答える 1

19

問題はコードではなく、プロジェクトファイルとインストールしたMSOfficeのバージョンの設定ミスです。適切なOfficeバージョンに一致するように編集することについては、関連するSOの投稿DebugInfoExeNamecsprojを参照してください。

Office Version | Version Number
---------------+-----------------
    2007       |   12.0
    2010       |   14.0
    2013       |   15.0
    2016       |   16.0

MS Office 2007の場合、プロジェクトファイルDebugInfoExeNameは次のようになります。

DebugInfoExeName = "#Software \ Microsoft \ Office \ 12.0 \ Outlook \ InstallRoot \ Path#outlook.exe"

于 2012-10-10T14:02:25.497 に答える