This project has moved and is read-only. For the latest updates, please go here.

Object reference is not set to an instance of an object without application context.

Nov 22, 2013 at 4:52 PM
Hi Tim,

First off, thanks for all your work on this library.

I'm trying to inject a tracking service into my WP8 application. My implementation looks something like this:
    public class TrackingService : ITrackingService
        public TrackingService(string trackingId, string userAgent, string appName, string appVersion)
            GAServiceManager.UserAgent = userAgent;
            EasyTracker.Current.Config = new EasyTrackerConfig
                    TrackingId = trackingId,
                    AppVersion = appVersion,
                    AppName = appName

        public void TrackPage(string pageName)

        public void Track(string category, string action, string label = null, int value = 0)
            EasyTracker.GetTracker().SendEvent(category, action, label, value);
This service is injected as a singleton when the application starts up. When I call SendView, I get an "object is not set to an instance of an object" exception. I'm assuming that since this is configured in a class library that it doesn't have application context in order to make the call.

I set AutoAppLifetimeMonitoring and AutoAppLifetimeTracking to false and that addressed the issue, but I'm looking for guidance on the best way to plumb in the application context to maintain lifetime tracking.

I don't want the WP8 phone project to know anything about the analytics library.

I tried passing in the application and using SetContext to no avail.