Fehler beim Zugriff auf COM-Komponenten

Ich habe ein Add-In für Microsoft Office Word erstellt. Die Verwendung des Add-Ins ist kein Problem, wenn Word als Administrator ausgeführt wird. Wenn Word jedoch nicht als Administrator ausgeführt wird, gibt es zwei häufige Ausnahmen für den Zugriff auf Multifunktionsleistenelemente.

Die erste Ausnahme:

Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Core.IRibbonUI'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000C03A7-0000-0000-C000-000000000046}' failed due to the following error:  could not be found. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND)).
   at Microsoft.Office.Core.IRibbonUI.InvalidateControl(String ControlID)

Dieser Fehler tritt auf, wenn das Steuerelement durch den folgenden Code ungültig gemacht wird:

ribbon.InvalidateControl("control-id");

Und die zweite Ausnahme:

Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error:  could not be found. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND)).
   at Microsoft.Office.Interop.Word.ApplicationClass.get_Selection()

Dieser Fehler tritt in der letzten Zeile des folgenden Codes auf:

object wdStory = Word.WdUnits.wdStory;
object wdMove = Word.WdMovementType.wdMove;
WrdApp.Selection.EndKey(ref wdStory, ref wdMove)

Wie kann ich dieses Problem beheben?

Antworten auf die Frage(6)

Ihre Antwort auf die Frage