views:

184

answers:

1

I'm updating an old c++ service to use WCF instead of RPC and there is an issue as to what type to use when sending and receiving a handle (HANDLE, void*..etc). In the updated service I currently have it using IntPtr, but this does not work when going from a 64 bit version of the service to a 32 bit version. The IntPtr can not deserialize because internally it is just a void* which will be different depending on which environment you run in.

This solves the problem because the RPC infrastructure never actually sends the handle value, rather a GUID that references the handle. This process is described in the following article:

See Context handles section

I'm looking for a WCF equivalent to this functionality. I could write similar logic myself on the service to do this, or even just change the IntPtr to a Int64, but I'm hoping there is something similar to RPC way.

Thanks for the help

A: 

I recommend that you redesign any code like this. The original reason for passing handles around may no longer be valid.

Also, I presume you were passing handles around between native clients and servers, but with WCF you'll be working with managed code. What will the managed code on one side be doing with the "handle" from the other? It may make more sense, for instance, to send a file path to the other side and let the other side open the file, rather than passing a file handle.

This code was probably created at a time when RPC was not an old technology. This suggests that the rest of it was also designed with technologies contemporary to RPC. It's quite likely that the entire application may need to be redesigned for the modern world. In that redesign, you will likely be using WCF to do the same kind of thing that is currently being done using RPC; but it won't be a one to one match.

John Saunders