
How to access and debug a C# dll from a C dll
Our enterprise wide application is being developed using Visual Studio .Net
and in particular
C#. One of the pieces of the suite is DataStage, whose
server is written in C so that it can be run on a Unix or on a Windows
platform. Basically I am required to export certain functions from my C dll
that are exposed to the DataStage server and then in turn take the data from
the server and pass it on to some C# objects and vice-versa. These exposed
functions are required to be outside of a class.
Currently I have tried two approaches. The first approach was to create an
intermediate C# dll that talks with the other C# dlls used in the
application and then use COM Interop to expose the interfaces to my C dll.
This works fine until I try and step through the intermediate C# dll in
debug mode. In which case it can't get it to step into the C# dll.
The second approach I have tried is to create a managed C++ dll that exposes
the necessary C style functions and has direct access to the C# code. This
approach works fine, except I need to maintain a pointer to the managed
class over several C function calls, and the compiler doesn't allow me to
declare a pointer to a managed class that is not declared within the scope
of a function.
Any suggestions would be greatly appreciated.
Thanks
Doug