I have two users of my software getting a MissingMethodException that seems
to be tied to certain today plugins being loaded. My call to my unmanaged
function is done near the end of my application's startup initialization.
This occurs after initializing a list control that is data bound to a SQLCE
database. I have found that if the user accesses an empty database or
disables the plugins, the exception no longer occurs. I was also able to
work around the exception by calling one of my unmanaged methods early in my
app setup initialization. I assume this works because the dll is loaded
before memory becomes fragmented (or before NETCF allocates additional
memory and does not leave enough to load my unmanaged dll???) and later when
the call that previously generate the exception does not because the dll has
already been loaded. I am thinking of using this approach of "pre-loading"
my unmanaged dll early in the app setup to fix this problem but wondered if
I am missing what the real problem is.
My app is built with VS2003 using C# and running on Windows Mobile 2003SE
devices. If no plugins are loaded, my app runs the code without a problem.
One user can reproduce this when he enables both Marsware WeatherPanel
v2.3.1 and SBSH PocketBreeze v4.3.08 (with ContactBreeze v1.0.16). With only
one of these plugins loaded, my app runs fine. My first guess was an out of
memory condition, but that in itself does not seem to be the case unless
fragmentation is an issue (see memory stats below). My other user reports
that Pocket Informant and any one of his SPB plugins (Pocket Plus, Weather
or Diary) will cause this. Is there any way to get more detailed information
as to the cause of the error? I placed a MessageBox call at the top of my
unmanaged function and it does not execute when the MissingMethodExeception
is thrown.
Code:
[DllImport("DnzUnmgd.dll", EntryPoint="RT_InstallWinProc",
SetLastError=true)]
private static extern int RT_InstallWinProc(IntPtr hwndInk, IntPtr
hwndManaged);
RT_InstallWinProc( hWnd, handle); <=== Throws
MissingMethodException
Main Memory Stats (with WeatherPanel and PocketBreeze plugins enabled):
Storage Free Program Free
After soft-reset: 4.44 11.47
After catching
MissingMethod 4.43 4.28
Exception
Main Memory Stats (with WeatherPanel and PocketBreeze plugins disabled and
additional data copied to main memory to reduce free memory):
Storage Free Program Free
After soft-reset: 1.64 7.24
After successful
unmanaged call 1.64 0.34
From the memory stats, I conclude that my app can startup in when there is
less than 9 MB free space, yet with the plugins loaded with over 15MB free
space, I get the MissingMethodException. Unless memory fragmentation is
playing a role, I don't see why the error would be caused by a out of memory
condition.
Any thoughts as to what is really going wrong would be appreciated.
Thanks,
Rich
|