m_installedLocation = Package::Current().InstalledLocation(); function does not work

Solution for m_installedLocation = Package::Current().InstalledLocation(); function does not work
is Given Below:

 winrt::Windows::Storage::StorageFolder  m_installedLocation{ nullptr };
 m_installedLocation = Package::Current().InstalledLocation();

Because of this code, my exe crashes. I am new to UWP projects. I downloaded some code from internet but it did not work because of these lines. I did some research on the internet and I guess it’s a security related issue but I couldn’t find an alternative function. What can i use instead of Package::Current().InstalledLocation()? Also the return value must be winrt::Windows::Storage::StorageFolder