Can't find PInvoke DLL error in Windows Mobile

前端 未结 4 1277
故里飘歌
故里飘歌 2020-12-18 23:27

I am having a lot of trouble getting a basic scenario to work on windows mobile 5.0 emulator. I have a winforms app that eventually calls into native code. Deployment work

4条回答
  •  无人及你
    2020-12-18 23:43

    Your problem is due to the fact that WM5 memory managment is crap. DLLs are loaded from top of slot to bottom while apps are loaded from bottom to top. If you don't have enough space between your app and your DLL, you will receive a "can't pinvoke" error.

    WM5 allocates 32 slots of 32Mb for applications to run into.

    Each time WM5 allocates memory for dll, it uses a minimum of 64Kb block, so if your DLL is 32K, it will take 64k, if your DLL takes 68k then WM5 will allocate 2x64Kb — 128Kb.

    When WM5 loads the DLL needed, it will always load at the bottom address of the previsouly loaded app, i.e. if app 1 has loaded 2×30kb DLLs, the first one will be loaded at address 0 to 64k, the second from 64 to 128, then your app will load its DLLs from 128kb, not 0, even if your apps runs into a separate slot.

    In order to make things work, you will have to load your app earlier or remove non-needed apps from the windows starup folder.

提交回复
热议问题