Alan Alan - 1 month ago 14
C# Question

Does just adding a static class in an application cause a get to be issued?

I inherited this code where the app class is called when the application starts. I don't understand one thing. Specifically in this code what causes the DataAccess class to be created? Note that in the application there is no reference anywhere else to the DataAccess class or App.dataAccess. Even so the class gets created.

public partial class App : Application
{
static DataAccess dataAccess;

public App()
{
InitializeComponent();

MainPage = new Test.MainPage();
}

public static DataAccess DataAccess
{
get
{
if (dataAccess == null)
{
dataAccess = new DataAccess();
}
return dataAccess;
}
}

Answer

There is almost certainly a reference to the property if DataAccess is being instantiated. If this is a WCF application, have you checked for any clues in the XAML binding?