I am having problems accessing a managed object from
unmanaged code. Specifically, I have a .NET forms
application with a web service proxy. The forms
application links to an unmanaged DLL which uses callbacks
to receive data via TCP. The data received in the
callback must be passed to a web service via a web method
provided by the proxy. So the callback (which is
unmanaged code) needs to access the proxy (managed object)
to send the data to the web service. I am able to pass a
pointer to the proxy into the unmanaged callback using
pinning pointers and am able to invoke the web method to
transmit the data. The problem with this approach is that
it results in memory leaks, I assume because the CLR
garbage collection is not taking place in the unmanaged
code. Any suggestions of how to correct this or sample
code for a similar scenario whould be much appreciated.
unmanaged code. Specifically, I have a .NET forms
application with a web service proxy. The forms
application links to an unmanaged DLL which uses callbacks
to receive data via TCP. The data received in the
callback must be passed to a web service via a web method
provided by the proxy. So the callback (which is
unmanaged code) needs to access the proxy (managed object)
to send the data to the web service. I am able to pass a
pointer to the proxy into the unmanaged callback using
pinning pointers and am able to invoke the web method to
transmit the data. The problem with this approach is that
it results in memory leaks, I assume because the CLR
garbage collection is not taking place in the unmanaged
code. Any suggestions of how to correct this or sample
code for a similar scenario whould be much appreciated.