2012-10-10 2 views
7

Dies ist das erste Mal, dass ich .NET verwende, um ein Add-In auf Anwendungsebene für Outlook zu erstellen. Mit einem Tutorial habe ich etwas Code geschrieben und es wurde erfolgreich erstellt, aber ich konnte den Code nicht debuggen. Während des Debuggens einer Warnmeldung wird Folgendes angezeigt:Debuggen des Add-Ins auf Anwendungsebene für Outlook

Sie können dieses Projekt nicht ausführen oder debuggen, da die erforderliche Version der Microsoft-Anwendung nicht installiert ist.

Ich verwende Visual Studio 2010 und MS Office 2007. Um den Code zu debuggen, was soll ich tun? Kann ich Code ändern, damit ich ihn debuggen kann?

hier ist der Code

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

Antwort

18

Das Problem nicht Ihr Code - es ist eine falsche Konfiguration der Projektdatei und dem MS Office-Version Sie installiert haben. Siehe related SO post regarding editing DebugInfoExeName in the csproj to match the proper Office version.

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

Für MS Office 2007, sollten Sie Ihre Projektdatei DebugInfoExeName sein:

DebugInfoExeName = "# Software \ Microsoft \ Office \ 12.0 \ Outlook \ InstallRoot \ Path # OUTLOOK.EXE"

+1

Für MS Office 2016 lautet die Versionsnummer "16.0". –

Verwandte Themen