1

I am attempting to write a dll in VB.NET for use with our various in-house apps and macros, to simplify maintenance of code that is duplicated across the various apps.

These legacy programs range from 32 bit VB6 and VBA to newer 64 bit VBA. Based on answers I found here and elsewhere I have been able to make a COM-visible dll work in either the 32 bit apps or the 64 bit apps, but I cannot figure out how to make both work at the same time on the same machine.

Can anyone explain the steps involved? Layman's terms, please, as I am not a professional programmer and am new to .NET.

S Stuart
  • 99
  • 1
  • 5
  • 2
    You are mixing architectures, you can not run 32-bit code inside of a 64 application. AFAIK. – Phil Feb 22 '17 at 15:22
  • http://stackoverflow.com/questions/1076414/c-sharp-directive-to-indicate-32-bit-or-64-bit-build and https://msdn.microsoft.com/en-us/library/office/ee691831(v=office.14).aspx may help – Nathan_Sav Feb 22 '17 at 15:26
  • 2
    If your DLL already works with both 32-bit and 64-bit callers, IMO you've done the hard part already; I'd think all that's missing is the 32-bit registry keys for it. The machine running 64-bit apps must have your DLL registered under the 64-bit hive; I'd try *also* registering the DLL under the 32-bit one, using 32-bit `regasm.exe`. Failing that, create the keys manually (or script them). You might want the .tlb to be in a separate folder though. – Mathieu Guindon Feb 22 '17 at 15:44
  • Microsoft doesn't support installing 32-bit and 64-bit versions of Office on the same PC, but you can have 32-bit Office and a 64-bit version of some other VBA host, or vice versa. If your Project's build settings specify "Any CPU", then your dll should work under 32-bit and 64-bit - You just need to ensure you have both sets of registry keys present and that you've registered the dll with the respective bit-specific `regasm`. – ThunderFrame Feb 22 '17 at 19:34
  • @ThunderFrame, that is my situation. I have 32 bit VB6, 32 bit Office VBA, and 64 bit SolidWorks VBA. I was trying to compile x86 and x64, so the tip about Any CPU was helpful. And I didn't realize there were 32 and 64 bit versions of regasm, so that was also part of my problem. The last piece of the puzzle was using the /codebase switch with regasm. I didn't think I needed it because I don't have a signed or strong named dll, but for whatever reason I did need it. Everything is working now. Thanks all. – S Stuart Feb 23 '17 at 19:43

0 Answers0