Outlook 64-bit

Add-in Express™ Support Service
That's what is more important than anything else

Outlook 64-bit
 
petgre




Posts: 48
Joined: 2014-04-29
I have an add in for Outlook, works great in 32 bit Outlook version.
The dll is depending on a separate dll, handling the communication between the add in and our crm system.
Upgraded to Office 64 yesterday. I compile the depending dll as any cpu, like also the add in. I can register it in Outlook 64. Works as it should. If I try to compile the add in and the dll as x64, it will not compile at all.

So, I created a setup via Wix. Tried to install it on another computer, also office 64 bit. The install will not work, as it says system.BadImageFormatException.

What do a do wrong?
As far as I understod, is that if you have a depending dll, it must be 64 bit if running in Outlook 64.
How can it work in my Outlook 64 but using any cpu, the dll i use is a 32 bit dll if i loook at it in notepad.

Please give my some ideas whats wrong :)
Posted 03 Dec, 2020 05:14:08 Top
Andrei Smolin


Add-in Express team


Posts: 18822
Joined: 2006-05-11
Hello petgre,

BadImageFormatException is about loading a 32bit DLL in a 64bit process or, vice versa, about loading a 64bit DLL in a 32bit process.

petgre writes:
As far as I understod, is that if you have a depending dll, it must be 64 bit if running in Outlook 64.


This must be so WHEN Outlook loads it. This means the Any CPU platform can simplify the things as .NET recompiles an Any CPU assembly to 64bit when it is loaded in a 64bit process. Also, Add-in Express is about add-ins built for the Any CPU platform. Using Any CPU also simplifies the setup project. Look into the setup project that Add-in Express generates for a newly-created add-in project: the add-in project is Any CPU and the setup project creates a single installer that works in 32bit and 64 Windows. The setup project uses the adxregistrator.exe utility which registers your add-in for both 32bit and 64bit Office.

petgre writes:
the dll i use is a 32 bit


You can't support a 64bit Outlook if you do not have a 64bit version of that DLL: it isn't possible to bypass BadImageFormatException. If you have a 64bit version of that DLL, check https://www.add-in-express.com/creating-addins-blog/2015/02/25/creating-bit-specific-office-addin/ on our blog.


Andrei Smolin
Add-in Express Team Leader
Posted 03 Dec, 2020 06:07:34 Top
petgre




Posts: 48
Joined: 2014-04-29
My SharedServices.dll is compiled with the AnyCPU as also the add-in dll.
I can register it in VB, and it works in outlook 64.

If i take the same files and use it in my wix installer, I get BadImageFormatException on the SharesServices.DLL in the other computers Outlook 64.

You say "as .NET recompiles an Any CPU assembly to 64bit when it is loaded in a 64bit process"
When does this happens?

//Peter
Posted 03 Dec, 2020 08:19:54 Top
petgre




Posts: 48
Joined: 2014-04-29
And now it works, dont really know what I did, but i must be related to anycpu!
Thanks for your support!

//Peter
Posted 03 Dec, 2020 09:42:50 Top
Andrei Smolin


Add-in Express team


Posts: 18822
Joined: 2006-05-11
Hello Peter,

Welcome!

petgre writes:
You say "as .NET recompiles an Any CPU assembly to 64bit when it is loaded in a 64bit process" When does this happens?


Check https://www.geeksforgeeks.org/what-is-just-in-time-jit-compiler-in-dot-net/ on geeksforgeeks.org and https://docs.microsoft.com/en-us/dotnet/standard/managed-execution-process on docs.microsoft.com.


Andrei Smolin
Add-in Express Team Leader
Posted 04 Dec, 2020 01:57:47 Top