Native Exception caused by calling unmanaged dll in .net CF

  • Thread starter Thread starter skyman
  • Start date Start date
S

skyman

I package a DLL by EVC++, and write a simple testing program to test it.
I simulate the target program to call the API by timer.
All the test passed, but once I integrate the API, calling the unmanaged
dll, into the target program,
it often caused native exception while the program execute the segment,
calling the unmanaged code.
It didn't happen always, just often.
But while I remove some declaration, it was caused less times.
The declaration is something about forms.
Is this problem possible caused by thread or some unsafe UI control ?
In the unmanaged dll, I used MFC, thread, and call another unmanaged dll.
 
There are way too many scenarios that would cause this for us to reasonable
help you with so little information. Are you passing handles/references
between managed and unmanaged code? How about memory addresses and
allocations?

-Chris
 
Yes, I passed references between managed and unmanaged code.
But....
There are 3 APIs, exported by the unmanaged dll, and the declaration is
like below in C#.
Basically, I think this dll work normally, like my before description, I do
the test in a simple program.
The test was done over 100 times, but it never cause native exception.
Even now I based on this simple testing program to modify as my target
program,
but as the program was more huge, the probability to cause native exception
was also increased.
(ps. it didn't happen always, currently it happen once every 15 times
launching )
The calling sequential is A->B->C.... It crash at A function sometimes, but
it often crash at B or C function.

Declaration:
[ StructLayout( LayoutKind.Sequential )]
public class WConfig
{
public IntPtr _sSSID;
public IntPtr _sMACAddress;
public ushort _lSsidLen;
public ushort _lMacLen = 0;

public ushort _lChannel=0;
}

public class LibWrap
{
[ DllImport( "GetSiteList.dll")]
public static extern void _A();

[ DllImport( "GetSiteList.dll",CharSet=CharSet.Auto )]
public static extern int _B( );

[ DllImport( "GetSiteList.dll",CharSet=CharSet.Auto )]
public static extern int _C([In]int index, [In,Out] WConfig config);

}
 
Back
Top