Question

I am little confused about using 32 bit interop dll with 64 bit process. In order to get access to 8TB of memory I am going to build my application for 64 bit, unfortunately it uses some statistical interop library which is build in 32 bit mode. I don't have sources for this library so I cannot rebuild it to 64 bit.

In this article the suggestion is to create 64 bit surrogate process that will communicate with my app using IPC (e.g. WCF). Here we can find the solution that uses Runtime Callable Wrapper (RCW). Which is better? I started to implement surrogate process and just today I found the second solution which I don't know if is suitable for my needs.

I need to mention that this statistical interop library has hundreds of interfaces and classes. Still I need just some of them. I have started creating WCF service hosting several of them as endpoints and it seems it will be a lot of code/work.

Can I use second method (RCW) to use with interop dll?

Regards, jotbek

Was it helpful?

Solution

Well, "better" is a loaded term. But, yes, COM surrogates can make it a helluvalot simpler to get this going. If you can use the system surrogate, odds are almost always good when the library was well designed, then you just need to duplicate the registry keys into the 64-bit keys and tweak a few of them to use the surrogate and it all works without you writing any code at all. The MSDN starting page is here.

It won't work out when the library doesn't support cross apartment marshaling. If you have no idea if it does then try calling a library function from a worker thread. If that doesn't work then don't bother trying. And you'll lose the "better" if this library is prone to crashing bugs, that invariably turns out poorly in an out-of-process scenario. Speed might be an issue, out-of-process calls have a lot of overhead. But you're stuck with that either way. You'll get good answers instead of SO guesses by contacting the library owner for support.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top