GetEntryAssembly for .NETCF

If your application contains multiple levels of DLL files, you may want to determine the name and path of the original calling executable. On the desktop you can use Assembly.GetEntryAssembly() but this is not available in the Compact Framework. I have added an equivalent to the SDF code to work in just the same way, using Platform Invoke. It uses the GetModuleFileName API which when passed IntPtr.Zero for the module handle, returns the path of the calling exe. Assembly.LoadFrom is then used to return the Assembly object corresponding to this path. Since the exe is already loaded this will not increase the overhead of your application. From the returned Assembly object you can determine the Path, Version etc as required.

The full code for AssemblyEx is available in the online Source Browser, and will be built into a future SDF release.