1

I need to run the vb6 32 Bit dll in .net application. When I run the application in X86 it works fine. But when I run the application in "Any Cpu" Configuration it gives Following Error:

Retrieving the COM class factory for component with CLSID {AAA4DA7D-FC03-4BF7-B240-FA6F323D41EE} failed due to the following error: 800700c1 is not a valid Win32 application. (Exception from HRESULT: 0x800700C1).

For the Code line

CommonUniqueObj = New Uniquekey.Class1

How to solve this error. I want to run the .net application in "Any cpu" configuration?

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188
IT researcher
  • 3,274
  • 17
  • 79
  • 143

2 Answers2

2

AX (COM) DLLs run in-process, and as the comments say, you can't mix x86 and x64 code directly.

One possible workaround is to compile the VB6 DLL as an AX EXE instead. 64-bit programs can instance AX EXEs and data can be marshalled between them, since they run in separate processes.

Jim Mack
  • 1,070
  • 1
  • 7
  • 16
  • Yep, one option is to compile the VB6 as an ActiveX EXE. Another is to build the .Net with the target CPU set to x86 – MarkJ Nov 30 '20 at 17:06
  • If the component is able to work out-of-process proper by just recompiling it to an AxEXE then you can try hosting it in a COM+ to the same effect first. The chances are not very high though. – wqw Nov 30 '20 at 20:23
0

You can mix 32 bit and 64 bit. By calling into an exe bitness doesn't matter. Data is marshalled as with any out of process call.

DLLs can be run in an exe by setting registry values.

See https://learn.microsoft.com/en-us/windows/win32/com/dllsurrogate

PS when using an exe it is a good idea to always set everytime just before you use it in case the user has terminated the dllhost.exe that hosts the DLLs.

user14797724
  • 109
  • 1
  • 3