We had a similar problem. We wanted ActiveX code written in Visual Studio 6
to communicate with a WebService in .NET.
The way we solved it was to create a Managed C++ dll that was also a regular
dll. Use the wizards to create a regular dll, then enable the support for
managed extensions.
The VS6 code calls functions in this dll which in turn calls the WebService.
The limitation of using a regular dll is that you can only use C types, no
CStrings. Since your code is written in C, this should not be a problem.
When implementing this we had a problem freeing memory allocated within the
DLL. From what I could understand, the runtime tracks which CRT the memory
was allocated on. In our case I think the managed DLL used VS.NET version
and the ActiveX used VS6.
In order to overcome this, we created a method called FreeMemory() in the
DLL, this frees the memory in the context of the DLL.
Chris
"Tim Nelson" <ti***************@softhome.net> wrote in message
news:eU**************@TK2MSFTNGP12.phx.gbl...
Hi,
I've got a legacy application written in C. I'd like to evolve the
product (as opposed to completely rewriting it) by adding new features using C#.
Is this possible? I know I should be able to call a managed-code DLL from C,
but I am unsure of the best way to do it, and also how I might marshal the
data between the two parts between the managed and unmanaged parts of the
application.
Can anyone point me in a direction?
Thanks.