简体   繁体   中英

Windows Phone Universal app throws AccessViolation when navigating

I'm developing a Windows Phone 8.1 Universal application and have the following issue.

The app has a number of views and their corresponding Caliburn.Micro ViewModels, two of which contain a MapControl with pins bound to an Observable collection of MapLocation objects.

The MapLocation class has as following:

public class MapLocation : PropertyChangedBase
{
    private string _title;
    public string Title
    {
        get { return _title; }
        set
        {
            _title = value; 
            NotifyOfPropertyChange();
        }
    }

    private Geopoint _geoPoint;
    public Geopoint GeoPoint
    {
        get { return _geoPoint; }
        set
        {
            _geoPoint = value; 
            NotifyOfPropertyChange();
        }
    }

    private Uri _imageUri;
    public Uri ImageUri
    {
        get { return _imageUri; }
        set
        {
            _imageUri = value; 
            NotifyOfPropertyChange();
        }
    }

    private bool _isMoving;
    public bool IsMoving
    {
        get { return _isMoving; }
        set
        {
            _isMoving = value; 
            NotifyOfPropertyChange();
        }
    }
    private Windows.Services.Maps.MapAddress _address;
    public Windows.Services.Maps.MapAddress Address
    {
        get { return _address; }
        set
        {
            _address = value;
            NotifyOfPropertyChange();
        }
    }
}

the list is updated frequently through a DispatcherTimer to show updated positions for all items.

The problem I'm facing is that every time I navigate to a page after having accessed it at least once, I get an AccessViolation exception and the app crashes.

I'm guessing that this probably has to do with some sort of cashing of my ViewModels.

Has anyone seen this behavior before?

Its a known bug. It seems like they are fixing it. https://social.msdn.microsoft.com/forums/windowsapps/en-us/fde433e8-87f8-4005-ac81-01b12e016986/debugging-access-violation-exceptions

Just give the delay before navigating

await Task.Delay(50); //Avoid Access Violation Exception //Naviagte

I hope this will solve your purpose for time being.

Logging for CM, can placed into Configure of bootstrapper or app.xaml.cs

LogManager.GetLog = type => new DebugLog(type);

This will help with issues with binding. As for digging into the exception, drop debug point at either main exception handler or back navigation, I suspect the collection...

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