WP7 Debugging without Tethering over USB? - debugging

i want to Debug some Networkproblem cases in my Application. But i can't really test it because my Phone has internet over USB. If I disconnect it from USB i can't debug... So is there anyway, I can disable the Tethering over USB on my Phone?
Edit: I have a HTC Trophy but it's the same with the Lumia 800 of my friend...

Assuming that you're connecting to a web service which isn't running on your machine, you can test this by disconnecting your PC from any network which gives it access to the internet (i.e. turn off wifi on the pc or pull the network cable.)
It's not an elegant solution or one that can be easily automated but it works. ;) (I used this method with testing an app which would progressively download large files in pieces and would stop and then resume as connectivity was lost and restored.)

You also can use Fiddler http://www.fiddler2.com/fiddler2/ as a Proxy for your emulator to simulate lossy connections or no connection at all. This way you can still surf and look for references while you code :-)
edit: fiddler doesnt seem to work for the Emulator(for more information, look into the comments), but if you want to simulate a lossy Connection then this is the way to go, even work for phones with the connection-cable.

Related

Hiding monitor from windows, working with it from my app only

I need to use a monitor as a "private" device for my special application, I want to use it as a flashlight of a sort and draw special patterns on it in full screen. I don't want this monitor to be recognized by OS (Windows 7) as a usual monitor. I.e. user should not be able to move mouse to that monitor, or change its resolution, or run screensaver on it or whatever. But I want to be able to interact with it from my application. Monitor is plugged using an HDMI cable to a video card (most probably nVidia).
What is the simplest way to do this? All solutions are appreciated, including purchasing additional adapters or simple video cards, or any other special devices. The only solution I could imagine for now is to plug the monitor to another computer, run a daemon on that computer, connect it to my computer via ethernet or whatever, communicate with that daemon from my computer. It is pretty ugly and require additional computer. But I need to solve this problem.
To do this, detach the monitor from the desktop. Detaching a monitor from the desktop prevents Windows from using it for normal UI.
Sample code for attaching and detaching monitors is in this KB article. Once you've done that, you can use the monitor as an independent display.
Building upon your own idea of using an external PC, and Mark's comment on using a VM as this "external" device:
You could buy an external USB-to-VGA video adapter like one of these, approx. USD40:
http://www.newegg.com/USB-Display-Adapters/SubCategory/ID-3046
Almost every VM software supports some kind of USB passthrough. VirtualBox is a great example.
Only the VM sees the USB device, the host ignores it completely.
So the steps would be:
Buy said USB-to-VGA adapter.
Configure slim a virtual machine and cook up a little utility to receive the images to show on he screen by network.
Configure VirtualBox to connect the USB-to-VGA adapter directly to the virtual machine.
Here is another simple solution to monitor you application.
Your app should provide an API monitor service, served as HTTP on any port you want (for example http://{userip}:{port}/{appname}/monitor).
Your app monitors itself, keeping monitoring data in memory, in a local file or a database, hidden from the user. The monitor API serves this data to any device you want that has a browser (tablet, phone, netbook, android mini-PC, low cost linux device, any PC or any OS... from the internet, your LAN or direct connection to the PC hosting the app).
Pros:
Data to monitor is collected (and served) within your app : only one executable
Display can be done remotely : from anywhere !
Access security easily done using standard HTTP authentication mecanisms
You can monitor several applications (ie several monitoring URLs)
You are free to use any browser to monitor (even a local window browser on the same PC for testing purposes)
Monitor from any hardware and OS you want
Simple and flexible !
Cons:
There is few, but tell me...
Choosing this solution depends on what kind of data you need to monitor (text, images, video...), and also on what is the refresh rate you expect depending on your system network configuration.
Hope it helps :)

WP7 Webbrowser/Http-request only working when connected to Zune

So I've been toiling over this app trying to figure out this strange behaviour and I'm just getting more and more confused so I thought maybe a more experienced WP7 developer could shed some light on the issue.
I have a (working?) application and I can run it perfectly fine when I'm running it though visual studio and even just when the phone is plugged into the computer but as soon as I disconnect the phone from the computer I can no longer send Httprequests and my webbrowser control no-longer loads pages from my server. Breakdown:
I open the app on the phone while it's plugged into the machine hosting the server and it works perfectly fine, no buggs, all requests go though and webbrowser navigates to pages.
Now if I unplug it from the computer while the app is running natively I lose all ability to make request or navigations (to server hosted pages) in my webbrowser.
Now if I plug it back in all the "Server not found" and "We're having trouble displaying this page" errors go away and my app returns to a usable state.
Is there some kind of permission that must be accepted before the phone can send and receive data from my server that is overridden when the phone is connected to the computer? Has anyone else run into this problem ever or do I just have something wrong with me? I'm am at a loss to find the issue, if you could point me in the right direction that would be great.
EDIT: Ok, so I think it has something to do with it being connected to a computer which is hosting the server. Because when I connect it to my mac (which doesn't have zune or any microsoft stuff) the app responds the same as not being connected (i.e no http or webbrowser)
Just tried running the app again while it was plugged into the server-computer but without Zune running and it did not work (i.e no http or webbrowser). So Zune is DEFINITELY and influencing factor, does anyone know what it's doing that I'm not doing when I unplug it or shut-down Zune? (note: the app is running natively, not through VS)
If I run it on a different computer with Zune running on it, it isn't working either, which I find strange....
Just found this: http://answers.microsoft.com/en-us/zune/forum/zune_install-pc/cannot-connect-to-server-or-dns-error-related-to/b224cffb-3ec0-456a-86f3-f9b931a92367 hopefully it will solve my problems.....we'll see....(Edit: couldn't find an answer here)
Thanks for the help!
Wow! I cannot believe I could have overlooked this. So the network that I thought I was using was different from the one my phone was using. Did you know that the windows phone (at least Lumia 800) automatically uses the internet from whatever computer it's plugged into and NOT the wireless network it's currently connected to if Zune is running on that computer? (well I didn't) On top of that the network that I thought it was connected to (and was using when I disconnected from the server computer) couldn't communicate with the network my server was running. This combination made it really hard to figure out what was going on and I spent WAY to much time trying to figure it out.
Thanks for the suggestions and sorry if I waisted anyones time.

Windows Phone - Application crashes when disconnected from PC

Whenever I disconnect my Windows Phone from PC (connected through USB) and if my application is running, my application hangs for sometime and then application crashes.
Does anyone experienced same behavior? I guess switching for PC connection to Wi-Fi/GPRS is causing the issue.
the windows Phone Requires that you Safely Remove hardware first, after a few times when i started Development on the windows phone i did the same and Ended up getting a new Phone. So plainly put, try to Safely Remove and Make sure it is installing the app to the Device.
Meaning if you Remove the phone, the App is still able to be ran just like a normal downloaded App form the Market place.
if you want more in depth information, i would suggest Reading the WP7 Everything Programming ebook lol
its filled with good information, and Definitely Helped me along my road to Love DEV for WP7.
As gamernb says, if you disconnect the USB from a properly tethered Windows Phone (i.e. connected to Zune, or using the WPConnect utility), the phone's network connection will be reset and your app's connections will be terminated. The phone will then start trying to connect using WiFi or cellular data (if they are on), but this can take quite a while.
You will have to handle this network disconnection in your app - I've found that pulling the USB cable in this way is a good ad-hoc test for WP7 apps: do an action which you know will use the network connection. Then watch if the app crashes, or handles this gracefully.
Actually you aren't guaranteed to always use the PC data connection: if you make sure that the computer has no data connection (i.e. pull the Ethernet cable, turn off WiFi etc ), the WP7 app can then use cellular data or WiFi on the phone instead.
Alas-
you could set perimeters in your application to Check what the connection type is, then Make changes accordingly.
You May have a slight freeze, but that's better then a crash....mainly when the phone switches from PC to WWAN, their would be a slight Pause.
use the Reachability Class and NSLog to Figure out whats going on exactly.
I really hope that helps!

Debugging Windows Phone 7 device traffic with Fiddler

I followed all the steps from the article but when I try to hit the server from my windows phone it says there is a dns error.
Article for reference.
http://blogs.msdn.com/b/fiddler/archive/2011/01/09/debugging-windows-phone-7-device-traffic-with-fiddler.aspx
How do I know my windows phone is using my local LAN WIFI as opposed to ATT cellular?
Personally, I use Netmon 2.3 for network traffic information from WP7. Fiddler didn't support WP7 up until recently and Netmon/Wireshark did, so I just stick with those.
Using Netmon 2.3, while your device is connected to Zune/WPConnect, you'd be able to see all WP7 device transport on the ZuneComm process. Netmon isn't as user-friendly as Fiddler, but it's fairly darn specific and easy.
You could turn on flight mode and then turn wifi back on.
Or you could take the sim out.
Either of those ways will ensure you're not using the cellular network.
I used the IP address instead of dns and it worked.

How do I debug wireless problems on a mobile app when it has to be wired to run in debug mode?

I'm trying to track down some bugs on a Windows Mobile 5.0 app. The testers can reproduce these bugs no problem, but I can't. They are using the devices across a wireless network, but I'm always running the app in an emulator, or on the actual device while it's in its cradle. In other words I always have a hard-wired connection.
I'm not sure how to approach this. Boatloads of logging? Is there some way to get Visual Studio to "Start Debugging" across the wireless connection? How does one effectively debug wireless connection issues on a mobile device?
You can get the debugger working over the wireless by manually running conmanclietn2.exe and cmaccept.exe, but the fact that the debugger is then using the connection may well affect your testing (depends on what the issues you're trying to find are). Your best bet is to use logging.
Another option to try is to enable the WLAN connection when you're device is in the cradle (I assume it now switches off the WLAN connection when you cradle it, which is the WM5 default).
If you're using Vista, go to the Windows Mobile Device Center and under Mobile Device Settings go to Connection Settings. Make sure the Allow Data Connections On Device When Connected To A PC option is ticked (I think the option is called the same in ActiveSync in case you're using XP). That way you will have an active WLAN connection when trying to debug through the cradle.

Resources