Outlook add-in won't install after Visual Studio upgrade

0

I have a Microsoft Outlook add-in that was fully working in debug mode but the click-once installer wasn't working.

So I decided to upgrade Visual Studio thinking that might help.

I then discovered that the reason I couldn't install was a corruption in the Add-in project, which was stopping the publish feature from working. The solution contains 10 projects (a mix of VB & C#), and the actual Outlook add-in project that references all of those projects.

I created a new Outlook Add-in project in the solution and moved all my code to that project and removed the old corrupt one. When I compile everything compiles correctly, no errors.

But when I debug this add-in project it fails to load with a System.BadImageFormatException. 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?

Here is the log from Outlook when it fails to load:

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?
visual-studio
outlook
add-in
asked on Stack Overflow Dec 21, 2018 by Craig Vertigan • edited Dec 26, 2018 by Craig Vertigan

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0