Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop Microsoft office word addin for 64bit version office in vs2010

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].

like image 971
Dah Sra Avatar asked Apr 29 '15 04:04

Dah Sra


People also ask

How do I upgrade Microsoft Office to 64 bit?

The 64-bit version of Office is automatically installed unless you explicitly select the 32-bit version before beginning the installation process. To install either the 32 or 64-bit version of Microsoft 365, Office 2021, or Office 2019, follow the steps in Install Office on a PC.

Does office use .NET framework?

NET Framework are required for each solution. Office 2013 and Office 2010 applications include the Visual Studio 2010 Tools for Office runtime.


2 Answers

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.

like image 184
Hans Passant Avatar answered Sep 29 '22 01:09

Hans Passant


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.

like image 40
Eugene Astafiev Avatar answered Sep 29 '22 00:09

Eugene Astafiev