6

I have developed an addin for word in vs2010.It's working cool in 32 bit version of office, but its not working on 64bit version of office .Searched a lot and found that

For 64-bit Root\Software\Microsoft\Office\application name\Addins\add-in ID
For 32-bit Root\Software\Wow6432Node\Microsoft\Office\application name\Addins\add-in ID

registry information path's.I tried register the information for 64bit.Even too its not working in 64 bit of office. In 64 bit office my addin was displaying under InActive Application Add-Ins.I even tried enabling it.

How to develop and deploy an addin for 64 bit of office..?

and am getting the following error ..!!

Could not load file or assembly 'xxxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

************** Exception Text ************** System.BadImageFormatException: Could not load file or assembly 'xxxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. File name: 'xxxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

 at MyWord.ThisAddIn.ThisAddIn_Startup(Object sender, EventArgs e)
   at MyWord.ThisAddIn.FinishInitialization()

at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases) at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints() WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Dah Sra
  • 4,107
  • 3
  • 30
  • 69
  • I think you maybe a bit confused, for backward compatibility the Wow64 is for 32 bit applications. Check the following [post to troubleshoot the addin loading](http://stackoverflow.com/a/14698249/495455) - check points 1,2,3,4 & 7 – Jeremy Thompson Apr 29 '15 at 04:26
  • @JeremyThompson but now i have got my registry details in Root\Software\Microsoft\Office\application name\Addins\add-in ID for office addin and its works perfectly for me in 32bit of office ,but its not working ( gettinbg enabled ) in 64 bit of office..? What might be the problem...? – Dah Sra Apr 29 '15 at 04:30
  • Do you have two versions of Office on the same PC? – Jeremy Thompson Apr 29 '15 at 04:32
  • @JeremyThompson no am having 32 bit version and its working fine in my system.But friend having 64bit version of office and the addin is not working in his system.. :( – Dah Sra Apr 29 '15 at 04:33
  • You need to clarify what you mean "is not working", eg it IS or ISN'T listed in the Word Add-Ins, it is listed but its not loading/showing, etc. Also please provide some ProcessMonitor logs of the registry keys to show which one's the Add-In is reading or at least where the add-in is looking in the registry. Also follow this guide and you're doing everything correctly: http://blogs.msdn.com/b/vsto/archive/2010/04/09/deploying-com-add-ins-for-64-bit-office-using-visual-studio-saaid-khan-for-nathan-halstead.aspx – Jeremy Thompson Apr 29 '15 at 04:40
  • @JeremyThompson Its listed but its not loading / showing in 64 bit of office version – Dah Sra Apr 29 '15 at 04:43
  • Ok and you tried all the VSTO troubleshooting steps I mentioned [here](http://stackoverflow.com/a/14698249/495455)? Also please post the ProcMon log to help diagnose the root cause. – Jeremy Thompson Apr 29 '15 at 04:47

2 Answers2

4

An attempt was made to load a program with an incorrect format

In 99% of the cases, that just means one thing when this exception is raised in a 64-bit program. The "incorrect format" is a DLL that contains 32-bit code. That cannot work, a 64-bit program can only load 64-bit DLLs.

If you used C# to write that add-in then it is a very simple fix. Right-click the project in the Solution Explorer window, Properties, Build tab. Set the "Platform target" to AnyCPU. Untick the "Prefer 32-bit" checkbox if you see it (VS2012 and up). Repeat this for the Release configuration.


Other possible explanations for this, the unusual cases:

  • Not having the 64-bit version of the .NET Framework installed
  • Writing code in the C++/CLI language, you have to build the x64 version
  • Having a dependency on a 32-bit unmanaged DLL
  • Accidentally loading the wrong DLL

You'll need SysInternals' Process Monitor to chase these kind of mishaps down. The trace shows you what DLLs the Office program is looking for and in which directories it looked for the DLL. It will be a big trace, work from the bottom of the trace backwards.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
2

Take a look at the Deploying an Office Solution by Using Windows Installer article in MSDN which describes all the required steps in depth. It states the following:

32-bit

  HKEY_LOCAL_MACHINE\SOFTWARE(32-Bit)\Microsoft\Office\Excel\Addins\SampleCompany.ExcelAddIn

64-bit

 HKEY_LOCAL_MACHINE\SOFTWARE(32-Bit)\Microsoft\Office\Excel\Addins\SampleCompany.ExcelAddIn
 HKEY_LOCAL_MACHINE\SOFTWARE(64-Bit)\Microsoft\Office\Excel\Addins\SampleCompany.ExcelAddIn

An installer for 64-bit Windows requires two registry paths because it’s possible for users to run 32-bit and 64-bit versions of Office on a computer that runs 64-bit Windows.

But you may detect (in the custom actions) the bitness of MS Office installed and create keys in the proper hive.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • the link which you shared is based on instaSheild ,but am using WIX installer. – Dah Sra Apr 29 '15 at 09:49
  • Good article, lucky for OP he has VS2010 which has the setup project. +1 – Jeremy Thompson Apr 29 '15 at 09:52
  • In the upper left corner there is a link to switch the article to VS2010. See [Deploying a Visual Studio 2010 Tools for Office Solution Using Windows Installer](https://msdn.microsoft.com/en-us/vsto/ff937654.aspx). – Eugene Astafiev Apr 29 '15 at 12:05
  • @EugeneAstafiev have even entered registry values in these two paths..though addin for 64 bit office is not working. – Dah Sra Jun 08 '15 at 05:11