We have an old 32-bit Visual Studio C# Windows Forms solution, which we want to compile from now on, in 64-bit. Unfortunately, our application uses some external dll-s (for scanners, cameras and so on) which are available only in 32-bit version. Accessing 32-bit DLLs from 64-bit code isn't straightforward, especially, when we want to handle also the events raised by those dll-s. Our knowledge at this area is unsufficient for creating an implementation based on this article, so we are looking for more detailed instructions or examples.
Our first attempt was based on this article. We wrapped the third party dll-s into a late bound 32-bit COM server and we used it from our 64-bit application as described here (mutatis mutandis, because we had to swap the roles of 32-bit and 64-bit). This attempt was successful, but incomplete, because this solution doesn't deliver the events from the COM server to the 64-bit client. So we started focusing on the events. We found a lot of articles and examples dealing with consuming events raised by the COM object, but none of them provides a complete solution for us. One part of the sources deals exclusively with the client, or exclusively with the server, but they are incompatible with each other, or with our environment (WinForm, c#).
For example,
- this answer tells us how to make a COM server which exposes .NET events to a VBA client, but I don't know how to use it from a c# client.
- In contrast this article gives a good working c# client for an existing COM server, but doesn't tell, how to make such a COM server (this COM server is visibly different from the previous example)
- this answer doesn't tell any details of the solution.
- This article is for c++ instead of c#.
- This answer refers to this article, but the latter uses again a VB client instead of c#.
- This article mixes different things in an untraceable manner.
Perhaps some of these can be used by us with some effort, but which and how?
Edit
Now I tend to create a hybrid solution: My newest idea for the backward communication from the 32-bit COM object to the caller 64-bit application is to put a Named Pipe server into the 64-bit application and a Named Pipe client into the COM object and every time when an event is raised in the COM object, it sends a Named Pipe message to the Named Pipe server. The code I found for this is available here (projects CSNamedPipeServer and CSNamedPipeClient).