Hi,

I have an application written in C# which will use some custom libraries
written in native C++. To bridge between the C# application layer and the
native C++ library side, I created an IJW assembly using mixed mode C++/CLI
and native C++. From the C# application side, I need to pass a window handle
to the custom library so that inside this library, it will do some drawing
on this screen. So, I from the C# application passed a Control.Handle to the
library. However, the moment the custom library tries to draw something on
this screen(I used SPY++ to trace it), it will crash when WM_PAINT is
called. The error is

AccessViolationException: Attempted to read or write protected memory. This
is often an indication that other memory is corrupt.

Why does this happen? How do I solve it ?. I have even tried creating a
window on the IJW library using CreateWindow("STATIC"...) and pass this to
the custom library for it to use but the problem still occurs. If this
window is hidden. the app will not crash. It will only crash the moment this
window is shown.

Anyone could help me on this? Thanks!!!!

John