Had lots of fun earlier trying to figure out why my Windows Phone 7 application could not connect to my WCF endpoint. I had tested things out thoroughly with a standard winforms client application and everything worked great, but whenever I tried hitting the same endpoint from my WP7 emulator I’d get the annoying error along the lines of “no endpoint listening” and if you look at the inner exception it was something like a 404 not found response. Of course this was completely silly, the endpoint was there. There were two things that I learned to resolve this:
- The error really meant that the phone emulator did not have the root certificate authority for the SSL cert in its list of trusted certs. Unfortunately even with the WP7 1.1 (i.e. Mango SDK), there does still not appear an easy way to do this. What you really need to do is put the root CA .cer file into a zip file somewhere, and then put it up on a web site where you can download it. It could be a local development server, you can email it to yourself at something like HotMail, etc. Navigate to that file from within the emulator and it will download it then show you the contents of the zip file. If you click on the .cer file then it will offer to install it for you. Take it up on this offer and it will put it in the list of trusted certificate authorities and you are good to go. Or so it may seem… (see the next item)
- The steps I described in #1 work great…until you stop and restart the emulator. It has no persistent state it seems so everytime you happen to stop it (or the many times it gets stopped itself and/or disconnected from Visual Studio) you have to repeat step 1 all over again. Every time. Painful as heck. Not sure if this is on the fix radar or not but I guess we’ll see.