How to access and debug a C# dll from a C dll 
Author Message
 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



Wed, 29 Dec 2004 06:05:29 GMT  
 How to access and debug a C# dll from a C dll
Douglas,

You can use a GCnld to store this pointer, or use the typesafe wrapper
gcroot we provide around a GCHandle.

Ronald Laeremans
Visual C++ compiler and libraries team


Quote:
> 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



Sat, 08 Jan 2005 01:26:22 GMT  
 How to access and debug a C# dll from a C dll
Something mungled the "GCHandle" into a "GCnld"



Quote:
> Douglas,

> You can use a GCnld to store this pointer, or use the typesafe wrapper
> gcroot we provide around a GCHandle.

> Ronald Laeremans
> Visual C++ compiler and libraries team



> > 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



Tue, 11 Jan 2005 05:07:06 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. How to debug VC6 dll from C# client ?

3. debugging managed C DLL used by C#

4. Accessing C++ DLLs (not ActiveX) from C#

5. C# .dll and access from VB

6. Access Violation (NTDLL.DLL): 0xC0000005 only in Debug Mode on NT and Win2k

7. Debug DLLs via Attach Process - can't always access

8. Access violation in user32.dll in debug mode

9. NTDLL.DLL access violation in COM server only when *not* debugging

10. Strange Debug IDE Messages - NTDLL.DLL Access Violation

11. Installation of VC++.NET DLLs (including debug DLLs)

12. debugging vb6 dll from c# dll

 

 
Powered by phpBB® Forum Software