I can't register COM .dll in my office.
OS - 64-bit Windows 7;
Target Framework of dll is 4.0;
Office is 32-bit Word 2007 (x86 Word 2007)
Addin sets Low Level Keyboard Hook and uses the following unmanaged methods
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool UnhookWindowsHookEx(IntPtr hhk);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SetWindowsHookEx(int idHook, HookProcedure lpfn, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr GetForegroundWindow();
Below all combinations I tried is shown. Notes:
- RegAsm 32 means performing
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe "my.dll" /codebase - RegAsm 64 means performing
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe "my.dll" /codebase - Normal (CU) means
HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\ProgID - WOW (CU) means
HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Office\Word\Addins\ProgID - WOW (LM) means
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\Word\Addins\ProgID - Registry entry(WOW-CU,Normal-CU and WOW-LM) means creating progID folder with Description,FriendlyName,LoadBehavior in appropriate registry directory which encoded above
- Output is AddinSpy output
When target cpu bitness!=RegAsm bitness RegAsm command fails, I will not show such obvoius entries in my list.
target=32,regasm=32,registry=WOW(CU),output=no output. Word 2007 doesn't see WOW-CU?
target=x86-64,regasm=64,registry=WOW(CU),output=no output. Word 2007 doesn't see WOW-CU?
target=32,regasm=32,registry=Normal(CU),output=
BadImageFormatExceptionBut addin works!target=x86-64,regasm=64,registry=Normal(CU),output=
Dll Path is not found.target=32,regasm=32,registry=WOW(LM),output=
BadImageFormatExceptionBut addin works!target=x86-64,regasm=64,registry=WOW(LM),output=
BadImageFormatException
I heard that Office 2007 doesn't support registration for all users (local machine) but it looks like it does, as 5 and 6 showed. I mean Word can see registry WOW node in LM. On the contrary, WOW6432 nodes in Current User ignored as 1 and 2 showed. So, Word can't see WOW node in CU.
How I can register my addin? 3 and 5 make it work but `BadImageFormatException is so annoying I want to ged rid from it.