问题
I've got a .NET CF (C#) mobile application that I run on a windows emulator. This application uses a sqlce database, and also is controlled by a number of config-like files. I frequently need to change back and forth between different debugging environments - i.e. I need different versions of the database as well as the config files - b/c the application is being used differently in each of the environments.
My initial thought was to use different emulators for different environments, but this doesn't seem very convenient. I could use the standard emulator for one environment and the professional environment in another, but sooner or later, I'll run out of emulator types. My VS solution (2008, btw) has something like 30 projects - so, I'd have to change the emulator type for each of the projects, which doesn't really help.
Another idea I had was to write a simple winforms or console app which could switch-out the environments for me (on the same emulator). That is, the app could copy the db and config files from some archive location on my machine, and when I switch to a new environment, it could copy the db from the emulator so that I'd always have the latest state archived. The problem I ran into with this is that there doesn't seem to be a way to access the file system of the activesync-connected emulator in code. Sure, I can see everything in Windows Explorer, but it doesn't seem available from code b/c the emulator doesn't have a drive letter.
Has anyone else been in a similar situation, and how have you dealt with it? I'd really like to get the second approach working (b/c then I could keep archives of my test data), but really anything that means I no longer have to manually copy these dbs + config files back and forth (in Windows Explorer) would help. Thanks.
回答1:
You should be able to save multiple copies of the emulator. The procedure below is how we do it. You could also use the same emulator instance with a local folder mounted on \Storage Card, and just swap out different files before staring your debugging. I'd go with the first option as there's less chance of screwing up, and less work in the long run.
In Visual Studio, select Tools > Options…, select Device Tools–Devices from the tree.
Select the emulator of choice from the Show devices for platform: drop down; select for example Pocket PC 2003 SE Emulator from the list and click the Save As… button.
- Enter in the Save As dialog and click OK button.
- Select from the Devices: list, and click the Properties… button.
- In the Properties dialog, click the Emulator Options… button.
In the General tab, check Specify RAM size:, Shared folder: enter C:\Storage Card. IMPORTANT! Be sure to create a C:\Storage Card folder on your drive before launching the emulator. (optional) In the Display tab, check Skin radio and enter path to you skin Click OK button.
To target the emulator for your project, select from the Target Device dropdown in the Device toolbar.
来源:https://stackoverflow.com/questions/7604886/is-there-a-good-way-of-switching-between-different-debugging-environments-on-win