c# - .NET external unmanaged library function throws uncatchable exception -


i'm using opennetcf library in windowsce .net compact framework 3.5 application. problem when call 1 of functions (networkinterface.getallnetworkinterfaces() specific), randomly throws uncatchable exception , crashes application:

 exceptioncode: 0x80000002 exceptionaddress: 0x03f928c4 @ nativemethods.wzcdeleteintfobj(intf_entry& intf) @ intf_entry.dispose() @ getallnetworkinterfaces() 

i've search web , bug reported in bug tracer of opennetcf community. unfortunately, nobody has fixed yet , i'm pretty sure nobody going fix it. i've got source code have myself. happy if managed catch exception, without crashing application.

the method throws exception native method imported in following way:

         //---------------------------------------         // wzcdeleteintfobj: cleans intf_entry object         // allocated within rpc call.         //          // parameters         // pintf         //     [in] pointer intf_entry object delete         [dllimport("wzcsapi.dll")]         public static extern void             wzcdeleteintfobj(             ref intf_entry intf); 

what can catch exception method?

i faced similar problem while using opennetcf library in windows compact framework. uncatchable native exception thrown randomly , crashed entire application. while investigating probable causes issue, know due memory leaks due system have ran out of memory or data misalignment.

i called gc.collect() reclaim memory inaccessible before calling opennetcf.net.networkinformation.networkinterface.getallnetworkinterfaces() method. , resolved issue , didn’t native exception thereafter.

gc.collect() method forces system try reclaim maximum amount of available memory. objects, regardless of how long have been in memory, considered collection; however, objects referenced in managed code not collected.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -