Debugging OnFileActivated in Windows 8 - debugging

I've associated my Windows 8 App with a file type. However when I open that file my app starts to open and then crashes.
I can't figure out a way to do this while the debugger is attached.
I assume there is something wrong with my OnFileActiavted method so I've resorted to changing random bits of code in that method. This isn't working, so I'm wondering how I should debug this problem.

Does this work? You can debug without launching the app immediately. You can also debug other people's apps.

Another approach:
Debugger.Launch();
When your app starts and execution reaches this line, your app will be stopped and VS will ask if you want to attach a debugger.

Related

VS2019 Live Share - is it possible to share console as well?

I worked on a Console Application with a friend today. Is it possible to share the default console during a Live Share session? What I mean is that we had to compile and run our program manually through the default Windows Terminal to see output(which wasn't the best idea, there was a ton of empty lines displayed every time we would input anything), and debugging was impossible because we just couldn't see the console (only the host could).
According to the docs, it's possible to share the terminal in both VS Code and Visual Studio, but I don't think there's a way to share the console that comes up when you debug a console app. The solution I see is simply sharing a terminal, running your app in it manually and if you want debugging, you can try attaching the VS debugger to the console app's process after you start it manually by following this guide.

My windows phone application runs when ran though visual studio (onclick of device button) but when I disconnect and run it doesn't?

I have written file picker code in my project. When i run the project in my windows phone by clicking on device button in visual studio, the app runs fine(I mean it opens pictures library and i can select a photo and preview it).
But when I disconnect my usb and then open the app in the phone and when i open pictures library on click of a button , the pictures library opens briefly and then the app crashes immediately(My app closes).
Can anyone please help me with this??
As written in the blog post , the AndContinue method run in a different process and to do so, the current running app goes into the background or even gets closed sometimes, that is what you are experiencing in your app as far i can tell but not sure why different things happening during debug & deploy.
There must be a callback inside app.xaml.cs specifically to handle the condition when calling application(which was sent into background) comes in foreground, read this blog post carefully & you'll understand as what you need to change in your code :
using-the-andcontinue-methods-in-windows-phone
http://blogs.msdn.com/b/wsdevsol/archive/2014/05/08/using-the-andcontinue-methods-in-windows-phone-silverlight-8-1-apps.aspx
I just dealt with this issue and one of the reasons why there are differences between debug and deploy is because of the suspending event.
During debug, the application does not actually get suspended until you manually do it through Lifecycle Events. This means that when you pick a file on debug and the app is put to the background to load the file picker, it is not actually suspended, while when the app is deployed, it actually gets suspended.
Look into your app_resuming method and OnSuspending methods in your app.xaml that may be causing errors not occurring during debug.

Android Studio starting in debug mode by default

I have been working on a project, and when I run the project in android studio it had been running correct and when I ran in debug mode it ran correctly.
All of a sudden, when I try to run the project normally, it pops up on the device waiting for debugger
and in the logcat I get this:
02-07 10:38:46.444 3968-3968/com.geog.test D/dalvikvm﹕ Late-enabling CheckJNI
02-07 10:38:46.784 3968-3968/com.geog.test W/ActivityThread﹕ Application com.geog.visitdub is waiting for the debugger on port 8100...
02-07 10:38:46.804 3968-3968/com.geog.test I/System.out﹕ Sending WAIT chunk
and it goes no further. I don't know why this is happening, there is no debug command in the manifest, I have killed the adb and restarted as I did with android studio.
It's a real pain in the a*** as I can't run the app without going through debug mode. If anyone has any ideas I'd like to hear them
Thanks
Restart your Android Device once and also check there should not be any breakpoints in your java classes.
The above suggestions were too invasive for me so I digged a little more into it. The following solution works for me in android studio:
Start debugging. (You'll get the wait chunk message here)
Select the Debug pane with the bug icon.
press the small cross at the side menu.
press "Force close" on your device.
Restart debugging.
In my case, there was an AsyncTask whose doInBackground() method called android.os.Debug.waitForDebugger(), and this was being picked up even in run mode. Disabling the line fixed it. Restarting the device didn't help.
try this , always work :
1 - close Android Studio and any other IDE you have opened (maybe you have Eclipse also running?) and emulator instances;
2 - remove USB cable from PC and restart your phone if you use one ;
3 - run adb kill-server from console;
4 - open Android Studio;
5 - click on run/debug;
6 - when the window to select the device appears, attach your device to USB and USB to your computer;
In my case it was a service to which I had added android.os.Debug.waitForDebugger(). The service was in a separate process by defining in the manifest android:process=":sepprocess"; after removing this line (such that the service is in the same process as the main activity), debugging started to work in the service and I did not experience the
I/System.out﹕ Sending WAIT chunk
anymore.
First clear all the break points from your project using ctrl+shift+F8 for windows or for mac cmd+shift+F8. Restart your android device. Then run
In my case, there are multiple debuggers. I have native code running in my app.
I cleared it by selecting the Debugger and Process from Run->Attach Debugger to Process
I deleted the emulator and recreated. It worked for me.

App crashes when being resumed

My wp7 app crashes when I come back from a task such as Map, Call or Web Browser. Infact, if i lock my phone and resume it again, still it crashes. Please tell me what could be the problem and how can I remove it?
There is a problem with you code.
Remove the application off the phone by starting a new emulator instance.
Open App.xaml.cs
Put a breakpoint in the method RootFrame_NavigationFailed and Application_UnhandledException
Now use the CallStack to find the root of the issue.
With no code posted (and in your case it could be ANYTHING in the project) you will be the best person to resolve your issue. If you can post a small reproduction on here we can take a look.
In application exit methods you probably should restore the data you dealt with last time before you quited

WP7 app won't launch from app list

I have a simple Windows Phone 7 application which is working perfectly when started from Visual Studio. However, if I deactivate the app (press Windows button or back button from the application's MainPage) and then click the app's icon to relaunch, the screen will flash and return to the list/home screen. I assumed this was an issue with the emulator but when I got a developer device I have the same issue.
Note that reactivating without a complete tombstone works (pressing Windows button from the app and then back).
I have no idea what causes this or how to proceed with debugging. Hopefully someone else has experienced this and knows a fix.
Turns out there is a bug, i found the solution here http://forums.create.msdn.com/forums/p/67522/416995.aspx
In short, it turns out that the Microsoft.Xna.Framework.Media.MediaLibrary class (which I am using to display pictures on applications main page) is not properly initialized when the user has not opened a media hub prior to you calling it. So picture collection properties are null or empty. The solution is to add a call to MediaPlayer.Queue.ToString(), it will force the initialization of the native media library allowing you to invoke the MediaLibrary later on.
Sounds like an unhandled error on startup is causing the app to crash.
Trap/log/handle/display any unhandled exceptions. Also check what you're doing on startup.
IF you are saving something (to Isolated Storage) after first run and then opening it on subsequent launches then that's where I'd look first.
If it works when launched from Visual Studio then this will probably be due to the way you are rebuilding/redeploying the app before launching it in that case.

Resources