How do you debug Share Picker extensions? - silverlight

I have registered my Phone 7 app as a Share Picker Extension. It works—my app is in the list of Share options and it gets launched and I can load the chosen image. Okay, great.
But then things go wrong in my code. I would like to be able to debug the issues, but I can't seem to keep the debugger attached.
I cannot debug this in the simulator, since the Pictures app (and thus the Share Picker functionality) is not present in the simulator.
I cannot debug this on the phone because as soon as I pick my app from the Share list, the debugger detaches... right as my app is "launching" again.
Is it possible to attach the debugger to a running WP7 app? Is it possible to keep the debugger attached? Am I doing it wrong? Any suggestions, advice or guesses are welcome because I'm tearing my hair out.

When doing M+V hub integration (sorry, haven't done any pictures hub integration yet) I initially used a crude debug technique (Messagebox.Show, etc. - like Justin mentioned) to verify what was being passed to the NavigationEventArgs of OnNavigatedTo and wrapped the whole method in a try..catch block to learn what was going on. I then refactored the code when I knew what could be expected. (Remember OnNavigatedTo will be called when your app is launched normally too and so e won't be populated in the same way.)
When the app is launched from a/the hub it creates a new instance of the app and there is currently no way to connect to this for debugging while the main page is being navigated to.

Great question. I'm unsure if that's possible. As far as I know, there's no way to attach the debugger to when the WP7 O/S starts an app (which wasn't triggered by the debugger).
Photo Share picker extensibility, music+Video hub extensibility and other O/S extensibility points seem to not play nicely with the VS debugger. Normally I resort to MessageBox.Show to debug any problems with WP7 O/S integration.

1) Connect the Device
2) Turn off Zune
3) Start C:\Program Files\Microsoft SDKs\Windows Phone\v7.1\Tools\WPConnect\x86\WPConnect.exe

To properly debug your application that uses the Media Library, you'll need to use the Windows Phone Connect Tool (WPConnect.exe) as described on MSDN. Jaime has some additional tips on his blog.
Once you are connected, you should be able to debug your application. Fingers crossed anyway. If that doesn't help, I'll dig a bit further.

It's not so much about the WPConnect tool. The nature of your application means that you have to have it closed and the user should pick a photo. Only after that the data is returned to the application.
You should read about the application execution model on Windows Phone 7. Also a good explanation is available here.
Initially, I would say that you should look at tombstoning (a good explanation here) but then again, the image returned will re-start the app and won't allow you to directly attach the debugger.

Yeah, looks like this is impossible...
All the answers above seem to be missing the point: I presume you're able to debug your app in the "standalone" mode (when it's launched normally), but not when it's launched via the Share Picker Extension. Am I write? This is the wall I'm hitting... :-(
I thought the proper way would be to attach to the process once it's launched.
I tried to use Debug > Attach to Process, then select Smart Device as the Transport and Windows Phone Device as the Qualifier... But in return I get the ugly "Unable to connect to 'Windows Phone Device'. Not implemented" message.
Bummer :-(

Related

Why my Xcode macOS app connects to an unknown remote server

a quick question for what is strange behavior in my opinion.
I'm developing an app which, for the moment, is meant to run fully locally, with no network access at all.
Well, since when I've introduced some 3d graphics I'm having this in the debugger log window (in light sky blue)
Please note that such (apparent?) CDN access was fully absent before the addition of a 3d scene.
Could someone tell me what Apple is asking to a CDN and, most important, how can I prevent such accesses that have not been explicitly authorized/configured by the end user?
Thank you
In this case "CDN" does not refer to a Content Delivery Network, but rather to Apple's CoreDisplay framework. The following command will show that these logs come from the framework:
strings /System/Library/Frameworks/CoreDisplay.framework/CoreDisplay | grep "client setup_"

Proprietary USB device access via browser... possible? Silverlight maybe? (Java is excluded for now)

Probably there are a lot of similar questions around, but since I know only few solutions to this which I am not sure will work for us, I am looking for something else, maybe new technologies...
What we have is this USB device which is not so fancy (of course, it requires a driver to be loaded), and it has couple of C++ dlls to help getting certain output from it. On top, we made a C# desktop application which makes use of the device in a more attractive way (plenty of interop inside).
So far so good, but to have the application lifted up to the web in order to gain more flexibility... What options are there?
Known solutions are:
1) ActiveX - kinda old technology and not cross-browser;
2) .Net 'applet' - not so common (is this even a solution?)
3) Java applet - well known, but JVM needed (since we went for C++ C#
maybe is out of scope);
4) Web service on the usb device itself - our device is very
light, we cannot have it there.
Are there other ways? Is Silverlight 4, 5 (maybe "out of browser") a feasable solution? What about these new technologies nowadays? Html 5 or something?
EDIT1: In particular I am interested in Silverlight. Is there a way using Silverlight?
EDIT2: I found this question: Can Silverlight access a .Net library that accesses a USB port? . What shall I understand from that? Is really Silverlight not a feasable solution for my scenario?
EDIT 3: VERY IMPORTANT!
These devices need to be used on customer side! People browsing must use them locally on their PCs!
Thanks in advance.
to have the application lifted up to the web [...]
Simple solution: Let the webserver (http server) run on the PC connected to the USB device, and use one of the webserver's interfaces like CGI to talk to your USB device. This way you need to code only a USB-to-CGI wrapper program, which can be C++ or C#.
Another way is to write a browser plugin.
The issue that you're going to face is that content in a browser is often run in a sandbox, in such a way that the web app does not have access to the computer. There are good reasons for this - security, primarily. One way to have some code running in the context of the computer is to have a browser plugin that can access the computer's hardware resources, but that can interact with browser content. Unfortunately, you may end up writing a different plugin for different browsers.
There do exist frameworks out there that make writing browser plugins more manageable. A simple search should turn up some of those candidates.
You can use Silverlight 5, it can give you access to your file system and USB storage device. If you want to get control for other USB device (printer, scanner, etc), you should give a device type. I know, Silverlight 5 works fine with a file system and web-cams...)

Avoiding all system messages and messages from other software

Here is the situation. The company I work for builds this piece of software in c that can make a Windows computer act a bit like a TV. Essentially, our piece of software is meant to be played full screen and content is displayed from the internet without the user having to ever touch the computer again.
The problem is that once in a while, the system brings up pop-ups like "Your Windows system is ready for an upgrade." or "Please renew your Norton subscription" etc. which the user has to periodically and manually remove.
Is there a way to display content full screen without being bothered by those warnings?
Yah, whether or not the development community agrees, Microsoft has several standards for when and why it might be acceptable to have exclusive use of the monitor.
The most official strategy is to use DirectX in exclusive mode. This is what games do, what windows media player does in full screen video with hardware acceleration enabled, etc... If your application is multimedia intensive (as suggested by TV like functionality), you should probably be using DirectX too. Besides giving you the exclusive display access it will also increase your applications performance while lowering the CPU load (as it will overload graphics work to the video card when possible).
If DirectX is not an option, there are a great number of hacks available that seem to all behave differently between various generations of windows operating systems. So you might have to be prepared to implement several techniques to cover each OS you plan to support.
One technique is to set your application as the currently running screensaver. A screensaver if really just an EXE renamed to SCR with certain command line switches it should support. But you can write your own application to be such a screensaver and a little launcher stub that sets it as the screensaver and launches it. Upon exit the application should return the original screensaver settings (perhaps the launcher waits for the process to exit so that it returns the settings in both graceful exits and any unplanned process terminations ie: app crash). I'm not sure if this behavior is consistent across platforms though, you'll have to test it.
Preventing other applications from creating window handles is truly a hack in my opinion and pretty bad one that I wouldn't appreciate as a customer of such software.
A constant BringWindowToTop() call to keep you in front is better (it doesn't break other software) but still a little hack-ish.
Catch window creation messages with a global hook. This way you can close or hide unwanted windows before they become visible.
EDIT: If you definitely want to avoid hooks, then you can call a function periodically, which puts your window to the top of the z-stack.
You could disable system updates http://support.microsoft.com/kb/901037 and remove the norton malware.
You could also connect a second screen so that the bubbles appear in the the first monitor.
Or you rewrite it for linux or windows ce.
One final option is to install software that reconfigures your os into a kiosk http://shop.inteset.com/Products/9-securelockdown.aspx
If you don't need keyboard or mouse input, how about running your application as a screensaver?
A lot of thoses messages are trigged/managed by Windows Explorer.
Just replace it with your dummy c#/winform.
By changing the registry value
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"Shell"="Explorer.exe"
You can specify virtually any exe as an alternative to explorer.exe
That's the way all windows based (embedded) system (ATM & co) do.
There's still few adjustment (disable services you dont need / dr watson & others), and of course, you'll want to keep a "restart explorer.exe" backdoor.
But that's a good start

How to send a notification to another PC?

Is there a way i can send a notification/message to another PC in C/C++? I think something like net send, but i don't know if there is another way to send a notification/message. I created an application which will run on every PC, and i want, that if my application has finished it should send a notification to my PC, that it has finished running. I don't know if there is a solution for my question, but if yes, could someone tell me, how to do that?
Thanks,
kampi
How about using sockets?
http://www.alhem.net/Sockets/tutorial/
Start by learning about WCF. http://msdn.microsoft.com/en-us/netframework/aa663324.aspx
We ended up building a system for alerting all of our retail locations of emergency situations by building a service that opens up a TCP channel using .NET Remoting. It just sits there and listens for notifications. Our command center has a program that can send out notifications to this service. The service is responsible for displaying the message.
The code is proprietary, so I can't share it, but that's the general idea. Remoting has been rolled into WCF, which is why I started by suggesting learning that.
It has been working very well for us for many years, and works just fine on newer versions of Windows (unlike Net Send) and it's faster than Net Send.
Edit - added
I hadn't heard of this until now but you could also look into msg.exe. it looks easier.
http://www.appscout.com/2009/03/vistas_msgexe_replaces_net_sen.php
If you want something like "NET SEND" use mailslots!
Here more info on MSDN: http://msdn.microsoft.com/en-us/library/aa365576.aspx
If you can't use net send, how about just creating a date-stamped temp file of some sort that your other PC looks for?
Make your application a Growl client
Net Send is an option, but I think it will annoy the crap out of you, as it sends console toast to your computer, which pops up in front of the tasks you are working on. Personally, I would find that incredibly annoying.
If you created the application, you have the ability to include notication code. As an example, you can set up a service on your box and write the code to contact that service. On a windows machine, this can be a WCF service. You can also wrap this in a windows service if you want to fire up non-annoying toast.
I am not sure how to set up C to access a service, so another option might be to drop something in a folder and have a file watcher tell you. A bit kludgy, of course.

What could be causing my WP7 app to crash on only some models?

I've been working on this problem on and off for about a month. I don't expect anybody to be able to give me a definitive answer. I'm just completely out of ideas at this point and could use anything.
The problem is that my app crashes on only some models of phones. I have an HTC surround and it runs fine. It has also been tested on a Samsung Focus and it works there to. It crashes pretty consistently on a HTC mozart. There are other phones it crashes on but I don't know what models they are. I don't have access to an HTC mozart so debugging has been very difficult.
I'm handling the application UnhandledException event and I have try catch around every background thread. The error handling code never runs.
What I know:
Sometimes it freezes and requires a press of the power button. At least once it required the battery taken out. Most of the time it freezes and then crashes.
Most of the time it crashes on the main menu, before everything displays.
It's not 100% consistent. Sometimes it works for a little bit, but never very long.
It's not because it's out of memory. Most of the time it crashes while using less then 8MB.
When all the exception handling didn't work I added debug logging. This slows things way down but at the same time the issue goes away.
These symptoms make it sound like a deadlock to me. Although I have gone over the code and there is no thread ever entering more then 1 lock at a time.
Any ideas on how I should track this down would be appreciated.
Edit: This is a WP7 version of my game. I've just been able to confirm with a volunteer with an HTC mozart that the simplest conversion of the code meant for to run on the web will crash on the phone. That's code has no networking, isolated storage, or sound.
I also should have mentioned that this has passed certification and was in the marketplace for a few days until I took it down because it got bad reviews (because it was unplayable for some people)
If the devices are locking up, then my suspicions would be to look at the areas where you are closest to the driver level/hardware, which (looking at your game) are:
the display
the sound
It could also be just about due to processing/CPU activity - but generally "User level" code shouldn't be able to lock up your phone - that functionality is reserved for kernel software.
The only way of really testing this is to get hold of a device where this "reliably crashes" (e.g. a Mozart) and to go through the process of disabling bits of functionality one by one.
If this is a Silverlight app, then I'd expect Microsoft to want to help - I'd contact them via AppHub and via their local Evangelist team - they'll have the means and the motivation to assist you.
I'm happy to assist on testing on a developer-unlocked HTC Trophy if that helps!
The only thing I can think of that's unique to the Mozart is that it has an 8MP camera and all others have a 5MP camera.
Are you using a CameraCaptureTask and expecting the returned image to be a certain size?
Other than that, what does the app do? what services and device functionality are you using?
Do you have any network access running on a background thread?
I had roughly the same problem when developing my WP7 app. As far as I can tell it isn't as much model bound as it is device bound. In fact I had my app deployed to 15+ Trophy's (my company gave all their employees one of those) and it would repeatedly crash on some of them all having the same firmware. Some of the feedback I got through the reviews seems to indicate that it also happens in the wild.
In my case the crash occurs primarily (only?) when the app is launched. There does seem to be a strong correlation between internet connectivity and crashing in that I can 'recreate' the crash by putting my phone in flight mode, unplugging the network cable from my computer and then deploying the app. In that case too it immediately crashes and no event or break point is ever raised.
My gut feeling tell me it might have something to do with the map control as that does tend to respond funky to poor connectivity when the application is loading (like displaying an error message that the card cant be loaded while simultaneously displaying the map)
Does your app also use the Map Control (in combination with a Pivot control perhaps?)
Some of the devices have issues where you need set things to "content" instead of "embedded resource" in your project.
Although i've more heard about that issue related to app startup time, as on some devices (HD7?) the load of the app was taking enough time that the app was never allowed to start, the OS thought it was taking too long and killed it.

Resources