在Visual Studio升级后,将不会安装Outlook加载项

时间:2018-12-21 01:50:25

标签: visual-studio outlook add-in

我有一个Microsoft Outlook加载项,该加载项在调试模式下可以正常运行,但是单击一次安装程序无法正常运行。

因此,我决定升级Visual Studio,以帮助您解决问题。

然后,我发现无法安装的原因是外接程序项目中的损坏,这导致发布功能停止工作。该解决方案包含10个项目(VB和C#的混合),以及引用所有这些项目的实际Outlook加载项项目。

我在解决方案中创建了一个新的Outlook加载项项目,并将所有代码移至该项目,并删除了旧的损坏的代码。当我编译所有内容时,都可以正确编译,没有错误。

但是,当我调试此外接程序项目时,它无法加载System.BadImageFormatException。所有项目均设置为作为“任何CPU”进行编译/构建。 System.BadImageFormatException推断它正在尝试在我的64位计算机上加载32位代码。但是将每个项目设置为“任何CPU”不应该这样做吗?我也尝试将每个项目设置为x64,并且结果相同。我该如何进一步解决此问题,以找出导致问题的真正原因?

这是Outlook无法加载时的日志:

Could not create an instance of startup object DocumentOneOutlookAddin2019.ThisAddIn in assembly DocumentOneOutlookAddin2019, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8b7a688d5b244ff2.


> ************** Exception Text ************** Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateStartupObjectException:
> Could not create an instance of startup object
> DocumentOneOutlookAddin2019.ThisAddIn in assembly
> DocumentOneOutlookAddin2019, Version=1.0.0.0, Culture=neutral,
> PublicKeyToken=8b7a688d5b244ff2. --->
> System.Reflection.TargetInvocationException: Exception has been thrown
> by the target of an invocation. ---> System.BadImageFormatException:
> Could not load file or assembly 'DocONE.ApplicationCache,
> Version=2.0.0.6, Culture=neutral, PublicKeyToken=6effde05e8b7c663' or
> one of its dependencies. An attempt was made to load a program with an
> incorrect format.    at
> DocumentOneOutlookAddin2019.ThisAddIn..ctor(Factory factory,
> IServiceProvider serviceProvider)    --- End of inner exception stack
> trace ---    at System.RuntimeMethodHandle.InvokeMethod(Object target,
> Object[] arguments, Signature sig, Boolean constructor)    at
> System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags
> invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)  
> at
> Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.CreateEntryPoint(String
> entryPointTypeName)    --- End of inner exception stack trace ---   
> at
> Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.CreateEntryPoint(String
> entryPointTypeName)    at
> Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.LoadEntryPoints(IntPtr
> serviceProvider)
> 
> 
> ************** Loaded Assemblies ************** mscorlib
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3221.0 built by: NET472REL1LAST_C
>     CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
> ---------------------------------------- Microsoft.VisualStudio.Tools.Office.Runtime
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Office.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Office.Runtime.dll
> ---------------------------------------- System.Core
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3221.0 built by: NET472REL1LAST_C
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
> ---------------------------------------- System
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
> ---------------------------------------- System.Configuration
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3062.0 built by: NET472REL1
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
> ---------------------------------------- System.Xml
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3062.0 built by: NET472REL1
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
> ---------------------------------------- System.Security
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3062.0 built by: NET472REL1
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Security/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
> ---------------------------------------- Microsoft.VisualStudio.Tools.Applications.Hosting
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Hosting/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Hosting.dll
> ---------------------------------------- Microsoft.VisualStudio.Tools.Applications.Runtime
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.dll
> ---------------------------------------- System.Deployment
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3062.0 built by: NET472REL1
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Deployment/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Deployment.dll
> ---------------------------------------- Microsoft.VisualStudio.Tools.Applications.ServerDocument
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.ServerDocument/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll
> ---------------------------------------- System.Windows.Forms
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3221.0 built by: NET472REL1LAST_C
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
> ---------------------------------------- System.Drawing
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3062.0 built by: NET472REL1
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
> ---------------------------------------- System.Xml.Linq
>     Assembly Version: 4.0.0.0
>     Win32 Version: 4.7.3062.0 built by: NET472REL1
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
> ---------------------------------------- Microsoft.Office.Tools
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.dll
> ---------------------------------------- Microsoft.Office.Tools.Outlook.Implementation
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Outlook.Implementation/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Outlook.Implementation.dll
> ---------------------------------------- Microsoft.Office.Tools.Common.Implementation
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Common.Implementation/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.Implementation.dll
> ---------------------------------------- Microsoft.Office.Tools.Common
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Common/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.dll
> ---------------------------------------- Microsoft.Office.Tools.Outlook
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.60301.0
>     CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Outlook/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Outlook.dll
> ---------------------------------------- DocumentOneOutlookAddin2019
>     Assembly Version: 1.0.0.0
>     Win32 Version: 1.0.0.0
>     CodeBase: file:///C:/MyWork/docone-addin/DocumentOneOutlookAddin2019/bin/Debug/DocumentOneOutlookAddin2019.DLL
> ---------------------------------------- Microsoft.Office.Tools.Outlook.v4.0.Utilities
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.30319.1
>     CodeBase: file:///C:/MyWork/docone-addin/DocumentOneOutlookAddin2019/bin/Debug/Microsoft.Office.Tools.Outlook.v4.0.Utilities.DLL
> ---------------------------------------- Microsoft.Office.Tools.Common.v4.0.Utilities
>     Assembly Version: 10.0.0.0
>     Win32 Version: 10.0.30319.1
>     CodeBase: file:///C:/MyWork/docone-addin/DocumentOneOutlookAddin2019/bin/Debug/Microsoft.Office.Tools.Common.v4.0.Utilities.DLL
> ----------------------------------------
> 
> ################################################################### Also I have the log from fuslogvw here:
> *** Assembly Binder Log Entry  (21/12/2018 @ 12:28:13 PM) ***
> 
> The operation failed. Bind result: hr = 0x8007000b. An attempt was
> made to load a program with an incorrect format.
> 
> Assembly manager loaded from: 
> C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under
> executable  C:\Program Files (x86)\Microsoft
> Office\Office16\outlook.exe
> --- A detailed error log follows. 
> 
> === Pre-bind state information === LOG: DisplayName = DocONE.ApplicationCache, Version=2.0.0.6, Culture=neutral,
> PublicKeyToken=6effde05e8b7c663  (Fully-specified) LOG: Appbase =
> file:///C:/MyWork/docone-addin/DocumentOneOutlookAddin2019/bin/Debug/
> LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache
> Base = NULL LOG: AppName = NULL Calling assembly :
> DocumentOneOutlookAddin2019, Version=1.0.0.0, Culture=neutral,
> PublicKeyToken=8b7a688d5b244ff2.
> === LOG: This bind starts in default load context. LOG: Using application configuration file:
> C:\MyWork\docone-addin\DocumentOneOutlookAddin2019\bin\Debug\DocumentOneOutlookAddin2019.dll.config
> LOG: Using host configuration file:  LOG: Using machine configuration
> file from
> C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
> LOG: Post-policy reference: DocONE.ApplicationCache, Version=2.0.0.6,
> Culture=neutral, PublicKeyToken=6effde05e8b7c663 LOG: GAC Lookup was
> unsuccessful. LOG: Attempting download of new URL
> file:///C:/MyWork/docone-addin/DocumentOneOutlookAddin2019/bin/Debug/DocONE.ApplicationCache.DLL.
> LOG: Assembly download was successful. Attempting setup of file:
> C:\MyWork\docone-addin\DocumentOneOutlookAddin2019\bin\Debug\DocONE.ApplicationCache.dll
> LOG: Entering download cache setup phase. LOG: Assembly Name is:
> DocONE.ApplicationCache, Version=2.0.0.6, Culture=neutral,
> PublicKeyToken=6effde05e8b7c663 ERR: Invalid assembly platform or
> ContentType in file (hr = 0x8007000b). ERR: Setup failed with hr =
> 0x8007000b. ERR: Failed to complete setup of assembly (hr =
> 0x8007000b). Probing terminated.

All projects are set to compile/build as 'any CPU'. The System.BadImageFormatException infers that it is trying to load 32bit code on my 64bit machine. But having every project set to 'any CPU' shouldn't do that should it? I have also tried setting every project to x64 and that has the same result. How can I further troubleshoot this to find out what is actually causing the problem?

0 个答案:

没有答案