Posted 18 December 2012 - 01:02 PM
It might be a bit late, but I found this thread whilst struggling with the same problem, I made some progress which may help others attempting the same thing. I am using firmware 4.2.0.1 on a Plus2, but it should work on a Plus (Plus 1?).
Everything worked when the executable loaded was small, however as it grew I ran into problems, here's what I found.
Don't run the loader programme in the debugger, it will just seem to hang at Assembly.Load, even if the loaded executable is loaded.
Don't use a debug build of either the loader or the loaded .pe file. I'm fairly sure you can attach to and debug the loaded process, but I haven't worked out how yet. Make sure your loaded executable is fully debugged on its own first.
Finally, put a Debug.print "Hello" statement right at the start of your loaded programme's Main(), so you can tell if a problem is with the load or with your executable.
This is important because that's what mine was doing, it looked like the load was failing, but actually it wasn't, the loaded programme was crashing as soon as it started. Even though it worked fine if it was deployed.
I traced the problem to static variables in the class with the Main() which were holding references to classes created in the Main() function. These were correctly set and then suddenly they were magically set to null, between 2 lines of code! I think (speculation alert!) that what happens is that if the .pe is loaded into RAM and started, the garbage collector moves the image in RAM and either moves or destroys these variables. When I removed these variables out of the class containing Main() everything worked fine. Static variables in other parts of the programme are OK.
On the Plus 2 I now have a small loader deployed which succcessfully loads and runs a 40k .pe file off the SD card.
YMMV, but I hope this helps.
Kev.