PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Native Exception caused by calling unmanaged dll in .net CF

Reply

Native Exception caused by calling unmanaged dll in .net CF

 
Thread Tools Rate Thread
Old 07-07-2003, 11:56 PM   #1
skyman
Guest
 
Posts: n/a
Default Native Exception caused by calling unmanaged dll in .net CF


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.


  Reply With Quote
Old 08-07-2003, 12:28 AM   #2
Chris Tacke, eMVP
Guest
 
Posts: n/a
Default Re: Native Exception caused by calling unmanaged dll in .net CF

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

"skyman" <skylerh@giga.net.tw> wrote in message
news:uCP5TPORDHA.1556@TK2MSFTNGP10.phx.gbl...
> 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.
>
>



  Reply With Quote
Old 08-07-2003, 01:34 PM   #3
skyman
Guest
 
Posts: n/a
Default Re: Native Exception caused by calling unmanaged dll in .net CF

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);

}


"Chris Tacke, eMVP" <ctacke@NOinnovativedssSPAM.com> ¦b¶l¥ó
news:O%23v$9fORDHA.1560@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
> 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
>
> "skyman" <skylerh@giga.net.tw> wrote in message
> news:uCP5TPORDHA.1556@TK2MSFTNGP10.phx.gbl...
> > 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.
> >
> >

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off