Reputation: 858
I am trying to debug an app built using Xamarin forms and is running on windows for now in C#, but I am having problems debugging even simple things, since the local variables in methods are not accessible to debugger. I even created a simple test below, and if I put breakpoint on output line, "hello" will be output, but in watch window it says test is not defined in context. This is a simple example, but same thing exists in other methods. I wonder if it has to do with method being async? Is there an option I need to enable?
protected override async void OnStart()
{
string test = "hello";
System.Diagnostics.Debug.WriteLine(test); // If I put breakpoint here, I can't see 'test'.
}
Upvotes: 1
Views: 1264
Reputation: 32775
I have reproduced your issue in Xamarin.Forms version 2.2.0.45. You could try to update Xamarin.Forms to the latest version. Right click the solution
-> Manager NuGet Package for Solution -> click the Updates button on the NuGet Package Manager tab -> check all client project updating to laset version just like the following screen shot
As for the asynchronous method you use, you could use the await
keyword in the method.
await Task.Factory.StartNew(() =>
{
string test = "hello";
System.Diagnostics.Debug.WriteLine(test);
});
If you have not used the await keyword ,the method will be invoked synchronously. And the statement will also be executed in the method.
Upvotes: 1