Debugging .NetCF program with PC .Net Framework

D

Dex

Hi Community,

Might sound a bit strange: But since .Net programs are generally
hardware-independent, I can start and operate a .NetCF executable (e.g.
compiled for ARMV4) on my PC without the need of an emulator, which is much
much faster. I comment out the few Platform Invokes and SqlServerCE calls I
have and I adjust the directory structure using conditional compilation. Now
I can test most of the program and
- I don't have to download the program to the device
- I don't have to use the soft keyboard on the device
- I don't have to use the sluggish emulator

Now I would like to persuade VisualStudio to use the debugger. I obviously
need to switch the project from .NetCF to .Net Framework for debugging. Do
you see a way?

Dex
 
G

Guest

Yeah, I also do this. Kind of cool, ain't it?

Here are my next steps to debug on the desktop:
1. Run the .exe
2. In Visual Studio 2005, menu Debug, select Attach to Process...
3. In the dialog that pops up, find your running program and double click it.
4. VS changes to debug mode, within your running app. Breakpoints, etc. work
as expected.
 
G

Guest

In my previous post, the original project is run directly.

Here are 2 more ways, where you launch debug direct from within VS:
Method A - Run the actual PPC project (.exe) with it's original defines (eg.
PocketPC will be defined). Therefore, you must check, in code at runtime, to
see what platform you are on. The end result is similar to the previous
post, but you can start debug from with VS.
1. Add a sibling project to your PPC project, say PPC_Desktop
2. Delete the Form1.cs (default start up form). You may or may not want to
delete assemblyinfo.cs also.
3. Add a reference (project) in PPC_Desktop to the PPC project. You should
get a warning, which you should heed, about unpredictable results.
4. In PPC_Desktop, program.cs, call PPC.Form1 (for example) instead of Form1
(which is gone).
5. Build and run.

Method B - Link the original PPC code into the PPC_Desktop project. Here,
when you build PPC_Desktop, 'PocketPC' will not be defined. So, you could do
#if stuff for compile time selection of code.
1. Add a sibling project to your PPC project, say PPC_Desktop
2. Delete the Form1.cs (default start up form). You may or may not want to
delete assemblyinfo.cs also.
3. Add all of the source from PPC to PPC_Desktop. Use Add > Existing
item..., select the appropriate files, and press the down arrow next to the
'Add' button and select As Link. To add a form, select the .cs and
Designer.cs, but not the resx. If you select the .resx, you'll get a message.
4. In PPC_Desktop, program.cs, call PPC.Form1 (for example) instead of Form1
(which is gone).
5. Build and run.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top