简体   繁体   中英

Visual Studio 2019 cannot view static variables defined at App level in Watch window

I have a Xamarin Forms app in Visual Studio 2019 and I have several static class variables defined in the App.xaml.cs file. I use these variables through out my application. However, when I am on a page of my app and add a property of the Static Class variable to the watch window, I receive the error message:

Watch Window Entry:

App.gvm_WaitingList

Error:

error CS0103: The name 'App' does not exist in the current context.  

This makes it very hard to debug when I cannot see the values of properties in these static classes. Here is how the variable is defined in the App.xaml.cs

public static VM_WaitingList gvm_WaitingList;

and then I initialize it in the App constructor as follows:

gvm_WaitingList = new VM_WaitingList();

In searching for a solution I did find talk about the immediate window and adding global:: before the item I want to watch. However, when I do that I get the following error:

Watch Window Entry:

global::App.gvm_WaitingList 

Error:

error CS0400: The type or namespace name 'App' could not be found in the global namespace (are you missing an assembly reference?)  

Any ideas how to get this to work?

I finally found a way to see these variables. If I prefix the variable in the watch window with the namespace, it will resolve the variable in the watch window. Here is the solution that fixed my problem:

(NOTE my namespace is UniversalCheckInHost) Watch Window Entry:

UniversalCheckInHost.App.gvm_WaitingList

I hope this helps someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM