I wanted to write my GUI using C#/.NET WinForms as it is a lot easier than MFC and more portable. But I needed to access some low-level functions packaged in MFC dll. So I needed to call unmanaged code and I found 2 usefull articles:
I tried the technique on PC. It works. When I tried it on Windows Mobile 6, it kept showing “Can’t find PInvoke DLL ‘nameofmydll.dll’.” I put both managed & unmanaged dll in the same folder. The message didn’t make any sense. I searched on internet, some people were saying the my MFC dll must be compiled for the right platform. I checked my target platform (under Configuration Properties\C/C++\Advanced\Compile For Architecture) and it was correct ARM4. It baffled me. Eventually, I tried to link to static MFC dll, and it works.
My theory was that MS didn’t include MFC dll (at least the version I need) with my Windows Mobile. Later, I found out from MS: “MFC8.0 (DLL) is not ensured to be on the device. ” Link to the article.