I made some real good progress today with my project involving Citrix virtual channels. The great achievement today was simple: being able to call into a COM object from C/C++ and letting that COM object do some work on behalf of the caller. Basically I’ve got a named C# pipe client which uses a custom protocol which I created(very rudimentary) which I’ve encapsulated into a C# Library. I want to reuse the client library in C++ but its written in C#.net and so I can’t just load it. So I’ve exposed the C# library as a COM visible assembly and by using some clever COM interop from microsoft was able to call into it. So basically this means that my C++ code calls into the C# Library via COM, that library handles the client and protocol sending mechanisms to a named pipe server – which is also written in C#.

I could have written the C++ code to call the named pipe server but I’d have to rewrite lots of protocol and name pipe client code. Plus if that ever changes, I’ve got to change it in two places – in the C++ code and in the C# code. Not good. Better to just reuse the C# code from C/C++.