In a smart device project I'm trying to Pinvoke a function that should supposedly be available in mscoree.dll. The associated definition is as follows:
[DllImport("mscoree.dll", EntryPoint = "#29")]
internal static extern int Object_GetHashCode(object obj);
You'll find this with Reflector in the internal class EE in mscorlib.dll. Note that this function is called from Object.GetHashCode().
I have a smart device test project that indirectly invokes Object_GetHashCode. When I run it on the desktop everything works fine. When I run it on an emulator, then I get the following error:
System.MissingMethodException: Can't find an Entry Point '#29' in a PInvoke DLL 'mscoree.dll'.
Why does this happen? Doesn't exactly the same mscorlib.dll run on the emulator and on the desktop? It seems so because when I look at the implementation of Object.GetHashCode() that comes with mscorlib.dll distributed inside the NETCFv35.ppc.armv4.cab then I see that it also calls EE.Object_GetHashCode(). Why can mscorlib.dll call into mscoree.dll and I can't?
EDIT:
The mscorlib reference in the Visual Studio project points to the following file,
C:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\mscorlib.dll (210kB)
but by default Reflector shows the contents of the following file:
C:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\Debugger\BCL\mscorlib.dll (920kB)
These files have different implementations for System.Object.GetHashCode(). The former is simply empty while the latter looks as follows:
public virtual int GetHashCode()
{
return EE.Object_GetHashCode(this);
}
In fact all methods in the former file seem to be empty and the much smaller size seems to hint into the direction that the former file is just a placeholder, so that VS can reference something?
Lastly, I tried to find mscorlib.dll in the files on the emulator but failed. The Installer log file says the install location is \Windows but there's no mscorlib.dll anywhere. Where is this stuff?
In general, I have a hard time Googling for answers when it comes to the CF, not sure why?
P.S. I'm trying to find an answer to the this question.