Null reference Exception

May 23 2006 5:33 AM

I am using callback delegates in my c# windows application.

Its windows control built Dll which get hosted in form or webform.

In the same App I am using Pinvoke for WIN32 API's and callbackdelegate.

These delegates are executing on server application.

API are using C calling convention declaration .

Since CLR in .net does not support calling convention I am using modopt option in IL file at the invoke of callback function and CdeclAttribute class in the code .

The code works fine But sometimes crashes throwing Unhandeled Nullreference Exception or saying ModuleName : Unknown or sometimes the Win32Dll name itself.

I have tried giving try catch block for all the functions throghout the LIB but still not able to catch this suddenly coming Nullreference Exception.

When I say ok for debug then it goes for JIT debugging and comes up with "There is no source code available". As per the observation it happens whenever the callback functions invoke or data transfer or stack memory not available.

How do I catch this Error at any case(as there is no Application Start for Windows control library)?

If anyone can put suggestions for the above problem will be appriciated.