Showing posts with label Emulator. Show all posts
Showing posts with label Emulator. Show all posts

Monday, July 04, 2005

Reading in Files on SmartPhone Emulator

The other day I made a post on http://forums.microsoft.com about trying to load input files on the SmartPhone SE Emulator, which you can find here. The problem, of course, is trying to figure out how the SmartPhone Emulator maps a portion of the desktop file system to its file system. The response I got was,

The easiest way is to use folder sharing. Under File\Configure\General Tab set the folder sharing directory to any directory on your desktop. Put your text files into that directory and they will be accessible from "\Storage Card\" inside the Windows Mobile OS.

Though these instructions were either for VS2003 or inaccurate -- I got the point. In VS2005 you can do something similar by going to the File Menu -> Tools -> Options -> Device Tools -> Devices -> Smartphone 2003 SE Emulator -> Properties -> Emulator Options. The Emulator Options button opens a Emulator Properties dialog box. In the General tab of this dialog, you can input a "Shared folder" path, which I did (Incidentally, if you hit F1 on this tab for Help, you will note that the only function not explained in the Help is the "Shared folder"! Hmm, maybe it's supposed to be self-explanatory).

However, we're not done yet. We still have to figure out a way to refer to this "Shared folder" in your code -- This is something I have yet to figure out. I tried one thing this morning, which was to create a file programtically on the SmartPhone Emulator and see if I could find it on the desktop. I ran this simple test code:

string FILE_NAME = "MyFile.txt";
if (File.Exists(FILE_NAME))
{
Console.WriteLine("{0} already exists.", FILE_NAME);
}
StreamWriter sw = File.CreateText(FILE_NAME);
sw.WriteLine("This is my file.");
sw.Close();


After the code completed, I could not find the file anywhere on my desktop's filesystem. I also tried "\\Storage\\MyFile.txt" and "\\Storage Card\\MyFile.txt" for FILE_NAME but no dice. If you create FileInfo or DirectoryInfo objects to look at the file, it appears to be using the SmartPhone-type filesystem (e.g. root dir is \ instead of, say, c:\).

Update (July 5th 2005, 3:35PM): As Vladimir's comment suggests, he followed up on his original reply to me on the message boards here. A copy of the post follows:

The directions were for VS2005 DE for configuration of the running instance of the emulator. There are three emulator configurations that exist - global, local saved and instance. The Global configuration is what you set under Tools\Options\Device Tools\Pick Platform\Properties\Emulator Options. The global configuration will be applied to an emulator if there is no local saved state. If you have created a local saved state - the global configuration is ignored until you clear the saved state. The instance configuration is accessed after the emulator is started via File\Configure (on the emulator itself) and is only applied to the instance that is running.

So if you start the emulator and click on the emulator File menu, select Configure option and then select General Tab - you should see the "Shared Folder" textbox.

The folder is accessed as "\Storage Card\". My guess is that you changed your global configuration but it was not applied because you had a local saved state. You can verify that the shared folder works correctly by craddling your emulator with Device Emulator Manager and using ActiveSync to browse the filesystem.

I tried this and it works perfectly.

Saturday, June 25, 2005

Connect to Device Failed

I have been unable to get the SmartPhone 2003 Device Emulator to work on my laptop. This is particularly frustrating because I have successfully run the device emulator on two different desktop machines at work. My laptop is a corporate system and, therefore, may have some firewall software or strange setting unbeknownest to me.

The error I get is identical to this thread on forums.microsoft.com. Basically, I try debugging a simple test application with the SmartPhone 2003 SE Emulator and I have to suffer through a long pause before I get an error dialog that reads, "There were deployment errors. Continue?" I have the option of selecting Yes or No... neither of which helps. In the Error List in Visual Studio I get "Connect to Device Failed - Conman HelpText System."

According to the help thread mentioned above, this connection error is most likely due to a problem with the ip of the emulator. By default VS2005 beta 2 uses TCP/IP as the transport to the emulator. Unfortunately there is no easy way to determine the ip of the SmartPhone 2003 emulator (though there is a way to do it in the PocketPC 2003 emulator). I then installed the Microsoft Loopback Adapter solution, instructions found here. This did not solve my problem either -- in fact, I get the exact same error.

Beyond this, I've tried just about every setting in Tools->Options->Devices->SmartPhone 2003 SE Emulator->Properties but to no avail. In addition, I foundthat the easiest way to test the connection setting was to employ the "Device Emulator Manager" found in VS2005 (Tools->Device Emulator Manager) rather than to attempt a debug execution on the emulator.

I'm going to give up for now and debug straight off the cell phone itself. This, however, was not a possible solution this past week because I did not have my cord with me.