Tuesday, July 31, 2007

How do I connect a CF emulator to the Internet?

I'm not a CF guy, so this one cost me more time than I would like to admit. Fortunately, one of the guys I work with helped me out.

1. Make sure Virtual Machine Network Services is installed. On the "Network Connections" dialog, right click the "Local Area Connection" icon and then left click properties. This will bring up the "Local Area Connections Properties" dialog (see the picture below). If Virtual Machine Network Services is not installed, you can install it by downloading and installing Virtual PC 2007 .



Windows 7:

2. Open the emulator's "configuration" dialog (File->Configure...).

3. Check the "Enable NE2000 PCMCIA network adapter and bind to:" checkbox and then select your computer's network card from the drop down list. Afterwards, left click the "Ok" button.

4. Configure your network card so that it connects to the Internet. Open the "Settings" dialog (Start->Settings), change to the "Connections" tab, and then double click the "Network Cards" icon. Next, select "The Internet" from the "Configure Network Adapters" dialog's drop down list. Finally, left click "Ok" in the upper right hand corner.

5. Configure your connection so that it will access the Internet directly. Double click the "Connections" icon on the "Settings" dialog. Next, left click the "Advanced" tab and left click the"Select Networks" button. On the "Network Management" dialog, you can either create a new location or just edit the work connection like I did below by left click the "Edit" button. Next, left click the "Proxy" tab and the check the "This network connects to the Internet" checkbox. Finally, left click "Ok" in the upper right hand corner three times to return to the "Settings" dialog.

6. Try using Internet Explorer to connect the Internet.

  • I had problems getting this to work at home. I finally got it working by first configuring the "USA Windows Mobile 5.0 Pocket PC R2 Emulator" and then saving its state (File -> Save State and Exit). Afterwards, I ran the "USA Windows Mobile 5.0 PC R2 Square Emulator" and it connected to the Internet. I saved its state and returned to the first emulator and it was working. I have no idea why this worked and I hate not knowing!
  • During the process of figuring this out, I managed to wipe out Active Sync. I fixed it by downloading Active Sync 4.5.
  • I also managed to kill the Device Manager by telling it not to load certain libraries. I fixed that by running the devenv /resetskippkgs command from the Visual Studio prompt.
Helpful links:

Friday, July 13, 2007

How do I upload & download files using WCF?

I'm looking for the best way to accomplish these tasks. What follows is the best information that I've found. I will periodically update this post as I discover more information.


WCF gotchas:
  • Don't forget to set the maxReceivedMessageSize attribute of your binding to something fairly high if you are sending large files.

IIS gotchas:
  • Increase the maxRequestLength, which represents maximum length in kilobytes, in the System.Web section of my web.config file in order to upload large files to your server (i.e., < maxrequestlength="65536"> ). Remember that the reason maxRequestLength in the System.Web section was set so low was to decrease your vulnerability to denial-of-service attacks.

Articles worth reading:

Thursday, July 12, 2007

How to generate an XSD file from an existing class

Since one of my co-workers ask me how to generate an XSD file from an existing class today, I decided to post an example of how to do it.

First, I need a class to convert, so I will generate an XSD file from this class, which resides inside of an assembly called MyClassLibrary.dll:

using System.Xml.Serialization;

namespace MyNameSpace
[XmlRoot("Customer", Namespace ="http://www.yates.com/BusinessObjects/2007/07")]
public class Customer
private string _firstName;
private string _middleName;
private string _lastName;

public string LastName
get { return _lastName; }
set { _lastName = value; }

public string FirstName
get { return _firstName; }
set { _firstName = value; }

public string MiddleName
get { return _middleName; }
set { _middleName = value; }

public string Name
if (string.IsNullOrEmpty(MiddleName) == false)
return string.Format("{0} {1} {2}", FirstName, MiddleName, LastName);
else return string.Format("{0} {1}", FirstName, LastName);
Next, a command prompt window is opened in the same directory as MyClassLibrary.dll.

Afterwards, the following command is used to generate the XSD:
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\xsd.exe" MyClassLibrary.dll /t:Customer

Finally, an XSD file called schema0.xsd is generated in the same directory as the assembly. It looks like this:

Monday, July 2, 2007

Unable to add a WCF service template to a converted project

I filed a bug at Microsoft's feedback web site on Friday because I was unable to add a WCF service template to a converted project in Visual Orcas March 2007 CTP.

It turns out that it wasn't really a bug. I was ignorant of the fact that you need to change the target framework from whatever it was originally set to (in my case ".NET Framework 2.0") to ".NET Framework 3.0" or ".NET Framework 3.5".