C# Interop problem with ASP.Net
I am using DllImport to call the win32 API of our own C++ dll.
The API takes pointer to pointer to struct. So I am passing reference of IntPtr to that API and getting the data . I am using Marshal.ReadIntPtr to get each pointer to struct and get the data within the struct.
If I call this API from any windows application (console) I am getting the proper output and everything works fine.
But incase of ASP.Net, when I call the API from the code behind, the data comes properly but, in many cases
the aspnet_wp.exe crashes. When I debug that, I found that till the page_unload of the web page everything works fine, and after that only suddenly the worker process crashes. Thus I felt there can be some problem in deallocating the Intptr which works as Pointer to Pointer to struct.
I tried to deallocate the IntPtr (which was allocated in C++ code) using Marshal.FreeHGlobal and Marshal.DestroyStructure. None of this worked for me and I dont have any solution for the same.
Looking forward for your reply.
Thanks and regards,
Jitendra
|