64 to 32 bit Interop - how?

前端 未结 3 1066
无人共我
无人共我 2021-01-04 07:25

I need to integrate some legacy 32-bit code - for which I don\'t have the source code, into a project in such a way that it can be called from a 64-bit .NET assembly. The or

相关标签:
3条回答
  • 2021-01-04 08:00

    Check out this blog post. You can reference a 32 bit COM assembly from a 64 bit .NET application using a runtime callable wrapper. The short version is the following...

    1. Use tlbimp.exe to create a 64 bit Runtime Callable Wrapper:

      tlbimp.exe foo.dll /machine:x64 /out:Interop.Foo.dll

    2. Register the COM assembly (not the RCW) if you haven't already:

      regsvr32.exe foo.dll

    3. Reference the RCW (eg. Interop.Foo.dll) from your application. Change your Build Configuration to x64 and let 'er rock.

    0 讨论(0)
  • 2021-01-04 08:09

    What you need to do is create two processes communicating with IPC. This way, one can be 32 bit, and one can be 64 bit. You need to create a 32 program which links with the COM object and exposes its API through some IPC mechanism such as a named pipe. This way your .NET program can access it from another process.

    0 讨论(0)
  • 2021-01-04 08:23

    The best approach is to make an out of process COM server that wraps your 32-bit DLL. You can then call this from 64bit code.

    Here is an explanation of the basic concepts.

    0 讨论(0)
提交回复
热议问题