Kostas Pantos
Kostas Pantos

Reputation: 41

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?

Upvotes: 4

Views: 536

Answers (2)

Sunil Kumar S C
Sunil Kumar S C

Reputation: 304

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.

Upvotes: 3

mvermef
mvermef

Reputation: 3924

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...

Upvotes: 0

Related Questions