C# 找不到或加载Excel VSTO加载项

C# 找不到或加载Excel VSTO加载项,c#,vsto,office-addins,excel-addins,C#,Vsto,Office Addins,Excel Addins,我正在尝试使用VisualStudioOffice开发工具编写我的第一个Excel加载项。我遵循以下示例:。因此,我的代码如下所示: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Excel = Microsoft.Office.Interop.Excel; using Office = Microsoft.Off

我正在尝试使用VisualStudioOffice开发工具编写我的第一个Excel加载项。我遵循以下示例:。因此,我的代码如下所示:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;

namespace ExcelAddIn1
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            this.Application.WorkbookBeforeSave += new Microsoft.Office.Interop.Excel.AppEvents_WorkbookBeforeSaveEventHandler(Application_WorkbookBeforeSave);
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        void Application_WorkbookBeforeSave(Microsoft.Office.Interop.Excel.Workbook Wb, bool SaveAsUI, ref bool Cancel)
        {
            Excel.Worksheet activeWorksheet = ((Excel.Worksheet)Application.ActiveSheet);
            Excel.Range firstRow = activeWorksheet.get_Range("A1");
            firstRow.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftDown);
            Excel.Range newFirstRow = activeWorksheet.get_Range("A1");
            newFirstRow.Value2 = "This text was added by using code";
        }

        // VSTO-generated code
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
    }
}
当我构建程序并启动Excel时,Excel会发出一条消息,表示无法找到或加载加载项,并显示以下代码:

Exception from HRESULT: 0x8004063E

****************************
System.Runtime.InteropServices.COMException (0x8004063E): Exception from HRESULT: 0x8004063E
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo)
   at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String solutionLocation, String manifestName, String documentName, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, Boolean useFastPath, IntPtr& executor)
   at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IDomainCreator.CreateCustomizationDomain(String solutionLocation, String manifestName, String documentName, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, IntPtr& executor)
我想问题不在于代码,而在于Excel加载外接程序的方式。我已经检查了应用程序级项目中提到的所有文件和注册表项是否都存在。(有趣的是,虽然我使用64位,但注册表项在注册表项中是32位的。我尝试手动将它们添加到64位注册表项中,但没有帮助。)VSTO加载项在Excel中激活


操作系统是Windows 7 64位,具有用户权限,我使用Excel 2013和Visual Studio 2015。

此问题的副本:。以下可能是解决方案:。Office呢?32位还是64位?如果是x64,请检查插件使用的所有DLL,并检查其输出架构(x86不起作用)此问题的副本:。以下可能是解决方案:。Office呢?32位还是64位?如果是x64,请检查插件使用的所有DLL,并检查其输出架构(x86不起作用)