VS 2015 won't break at breakpoint in web api project - wpf

I have a VS2015 solution with 2 C# projects. A WPF client, and a Web API server. I set a breakpoint in the Web API code. Then ran the WPF client in debug. The breakpoint icons in the source file changed from solid red dots to red circles. The debugger is not breaking at the breakpoints. What am I doing wrong?

You effectively have 2 applications and you're trying to debug both at the same time which won't work.
Make your API run in IIS then use a separate Visual Studio instance to attach debugging to that process ( you can find it running under w3wp ).
So you can do this effectively with 2 instances of Visual Studio, one for the client and one for the API.
You can also simply open the same solution with a second VS, and run the API from there then have the client hit the api on the same URL as the one being debugged. It is a bit strange to use 2 Visual Studio instances but it does the job quite well.
Use whichever method you're more comfortable with.

I'm not 100% sure, but I think it is probably because you are just debugging the client. I had the same difficulty getting to the code of a WCF service recently. As I understand it (and I'm no expert, so people who know better feel free to correct me if I'm wrong) basically Visual Studio won't peek into the server code while you are just debugging the client. I presume that when you run the client, you also have the server running at the same time?
I think the best way to deal with this is either to start your client, and then attach the VS debugger to the server process (see https://msdn.microsoft.com/en-us/library/3s68z0b3.aspx), or to run both the client and server programs at the same time when you start the debugger (https://msdn.microsoft.com/en-us/library/ms165413.aspx).
Hopefully this helps :)

Related

How to debug a code on Logic-Apps?

I'm using Logic-Apps for my project now. I think it's good and easy! However, It was difficult to debug during the coding of the logic. Because I couldn't to confirm the variables or status at a middle point of the code. Usually a developer can detect the variables during the execution of program on Visual Studio. How can I debug the code on Logic-Apps? Do you have an idea?
At the moment, Logic Apps can only run on Azure, thus while you are developing a workflow, in order to debug your code, you need to run it on Azure. Once you run it, you can see the inputs and outputs of each action for that instance, including setting variable actions.
You can see in the documentation how to monitor each instance and the inputs and outputs of each action.
HTH

Debugging the server project while running out-of-browser?

When I start my Silverlight 4 and 5 applications with debugging in VS 2010, I can set breakpoints in both the client project as well as the server project that serves the application.
On running the app out-of-browser (ie configuring the app out-of-browser and setting it as the startup project) however, the debugger will not be attached to the server any longer, although the server project will still be started correctly.
Is there a way around this problem?
You can set a Launch or Break statement at the location you want to break.
// Will launch a debugger once and will break once
System.Diagnostics.Debugger.Launch();
//Will launch a debugger and break any time the code is hit
System.Diagnostics.Debugger.Break();

IIS related System.ExecutionEngineException

After too many hours of research I have come up with nothing to solve this problem.
I am running a WPF program in an .xbap page file being hosted on internet explorer. Running the project in Visual Studio 2010 works just fine and generates no errors.
I want to be able to host the webpage on IIS 7.0 and to browse to it with a windows forms application. To test this I created a new website on port 80 in IIS manager. I then published the project to the local website folder and added the autogenerated project certificate file (projectName_TemporaryKey.pfx) to my Trusted Publishers and Trusted Root Certification Authorities.
My problem is this: whenever I try to browse to the file with internet explorer or with my windows forms program, the wpf program stops working. When pulling up the just-in-time debugger, I am informed that there is a System.ExecutionEngineException but am given no source code, no stack trace, and no data outside of an empty Dictionary enumerable. My guess is that this might have something to do with the database call made in the program to another machine, but I can't prove that.
I've tried several things to solve this including repairing my .NET 4.0 framework and altering permissions but nothing seems to be affect the error.
Does anyone know of a way to get more information on this error, or perhaps a step I may have missed when publishing this project?
Thanks very much.
Some things to check:
Windows event log often includes additional exception information (although usually in an awful format)
Output some trace information from your application so you can follow what's happening
Try attaching a debugger to the WPFHost and then stepping through the code

System.OutOfMemoryException and a few exceptions happen during application run, Visual Studio 2010 WPF C#

I just discovered this problem today, and I had no idea what caused this problem. My project had been developed for few months.
I have a project(solution), with several projects in there, it works well if I write and debug, by pressing F5.
The problem occur is when I press Ctrl+F5 (to skip debug mode), or run directly from double click the exe, it crashed. The errors dialogs that pop up every times are different, but OutOfMemoryException is the most frequent one.
I had checked to make sure all my projects are .Net 3.5
I put a MessageBox.Show("something") at the beginning of my main project constructor, but it never reach.
I use some registry cleaner to clean/fix my registry, scan for viruses.
I had try to read the meaning of each error and exception, but still no clue why it happen.
These are a series of screenshots if I press Ctrl + F5. (FutureGenerator is some random name I gave to my project.)
Series of screenshot if I run the app from my debug folder, FutureGenerator.exe
I suspect this is caused by framework crashed during Windows Update, but I removed those update that I performed recently, still same. The exe file works on other non development PC, but I don't want to reformat my PC or reinstall my VS, yet, because it's a painful process.
Any idea, anyone?? Million thanks.
You mention v3.5 but the very first screenshot is about v4.
Try repairing your Framework 4 and/or VS2010
I found the problem. It's actually because I added FutureGenerator.exe into Application Verifier by Microsoft. The verifier only support debugging testing.
After I removed FutureGenerator.exe from the Application Verifier, everything's ok.

How do you debug Share Picker extensions?

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 :-(

Resources