Comments (23)
AutoAnalytics.StartAsync should be called directly before Window.Current.Activate() in your App.xaml.cs
If you start it too soon then yes, the Window.Current won't be initialized yet.
from csharpanalytics.
I do call AutoAnalytics.StartAsync right before Window.Current.Activate(); in my App.xaml.cs as mentioned in the documentation but still got the same problem.
from csharpanalytics.
Are you sure Window.Current is null or is it Window.Current.CoreWindow?
If Window.Current is null then the very next line, Window.Current.Activate, would also throw a null ref errror.
Have you changed anything else in your OnLaunched method?
from csharpanalytics.
Yes I'm sure Window.Current is null.
As for your next argument unfortunately that is not true. The problem is that the call that is throwing the exception is made from an other thread and not the UI one. In the UI thread Window.Current is not null, in the thread that is picking the screen size though, it is.
Hope this helps.
from csharpanalytics.
@damieng : Firstly thanks for this solution of yours. It is helping us a lot . :)
You are suggesting that we should add the call to AutoAnalytics.StartAsync in OnLaunched() , but the thing is that this is making the application launch slow . When the windows.current line is executed the splash page is removed and the user is able to see the application default page. We used it the first time as suggested , and the application didn't passed the windows certification giving reason that the application launch time was too much . So we moved the call to the OnNavigation() of the default page. This time we passed the store certification.
In our next release after we added some features to the application, on checking the application with the windows certification kit , the application failed, In the event logs, we found out that the application was failing with an exception in the CSharpAnalytics.WindowsStore assembly . So we removed all the calls to the reference assembly , and compiled the same. This time the application passed the certification.
Is it possible to remove the functionality to check the resolution of the user device , because that is where I think the exception is occurring , also one can work without this functionality.
Thanks.
from csharpanalytics.
At least some of AutoAnalytics.StartAsync will need to be on the UI thread but most of it is very lightweight - about the only thing that could cause much of a delay would be restoring the queue of pending requests (CSharpAnalytics-RequestQueue in the LocalState folder)
Where is your AutoAnalytics.StartAsync() line right now when you get the null ref?
from csharpanalytics.
Also check that CSharpAnalytics-RequestQueue file and see how bit it is. If it is large, did you change any of the CSharpAnalytics configuration? The sample app on my machine runs AutoAnalytics.StartAsync in ~100ms.
from csharpanalytics.
Hello Damien,
Regarding my null reference exception, the code is exactly as described in the documentation in the OnLaunched I call :
//Google Analytics
await AutoAnalytics.StartAsync(new UrchinConfiguration("XXXXXXXXX", "YYYYYYYYYY"));
// Ensure the current window is active
Window.Current.Activate();
SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested;
from csharpanalytics.
I'm very confused. I thought you said you had moved this code because it was slow? Or was the change made elsewhere?
If you comment out the AutoAnalytics line in the code above does Window.Current.Activate not also throw a null ref?
from csharpanalytics.
I'm not the one that made the comment about being slow.
It works quickly with me and had no problem passing certification.
from csharpanalytics.
P.S. To work around the issue I have commented out the code that measures the window height.
from csharpanalytics.
I see. @g10kumar can you put your issue on a new thread please, thanks!
Window.Current is initialized in OnLaunched before this line should be hit (Window.Current.Content = rootFrame) Are you perhaps trying to call AutoAnalaytics Track methods before StartAsync?
from csharpanalytics.
No I don't think so, the code worked perfectly in an older version of CSharpAnalytics. The problem was introduced once I've upgraded to the latest bits.
I haven't made any other changes except the upgrade of CSharpAnalytics.
from csharpanalytics.
Can you check your Debug output window to see what the first -Analytics-- block says for Event Type and Event Action?
from csharpanalytics.
-Analytics-------------------------------------
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
?utmwv=5.3.3csa1&utmn=2077949686&utmul=el&utmcs=UTF-8&utmfl=-&utmje=-&utmsc=32-bit&utmac=ΧΧΧΧΧΧΧ&utmhn=ZouglaW8.gr&aip=1&utmhid=1427415232&utms=14&utmr=http%3A%2F%2FZouglaW8.gr%2FLive&utmcc=__utma%3D1.172746138.1365604681.1365604681.1365604681.1%3B&utme=5%28ApplicationLifecycle%2AStop%29&utmt=event&utmp=%2FLive
Account ID : ΧΧΧΧΧΧΧ
Host Name : ZouglaW8.gr
Page : /Live
Referring URL : http://ZouglaW8.gr/Live
Hit ID : 1427415232
Hit Type : event
Event Type : ApplicationLifecycle
Event Action : Stop
Visitor ID : 172746138
Session Count : 1;
Session Time - First : Wed, 10 Apr 2013 14:38:01 GMT
Session Time - Last : Wed, 10 Apr 2013 14:38:01 GMT
Session Time - Current : Wed, 10 Apr 2013 14:38:01 GMT
Language : el
Encoding : UTF-8
Flash Version : -
'Zougla.exe' (Managed (v4.0.30319)): Loaded 'D:\Work\Zougla\Metro\Zougla\bin\Debug\AppX\Newtonsoft.Json.DLL', Symbols loaded.
Java Enabled : -
Color Depth : 32-bit
Tracking Agent : 5.3.3csa1
Cachebuster : 2077949686
Session Hit Count : 14
Anonymize IP : True
from csharpanalytics.
It's strange the first thing it's trying to send is a Stop event. Can you post the stack of the null ref?
from csharpanalytics.
HI,
@kpantos : can you tell me where do I have to make changes to stop the measuring of height .
@damieng :Where I will be able to find the CSharpAnalytics-RequestQueue file . I am calling the AutoAnalytics.StartAsync in the OnNavigatedTo page of the default page . Will this effect the performance.
from csharpanalytics.
@g10kumar Please open a separate issue for your performance problems. It is unrelated to the reasons this issue was opened and is confusing the discussion here.
from csharpanalytics.
Am now seeing the null ref while using a test app. Investigating.
from csharpanalytics.
It appears to happen when tracking unhandled exceptions.
from csharpanalytics.
Fix is checked in. Let me know if that solves your problem too @kpantos.
from csharpanalytics.
I've also been experimenting with a new start-up process on the Measurement Protocol version of AutoAnalytics (AutoMeasurement). It lets you Track events right away and just buffers them up until StartAsync has done its work (which no longer needs to run on the ui thread). This should resolve the null refs and any perf issues. Let me know if you want to try this.
from csharpanalytics.
So the new system is in. You'll need now to add two lines to the app.xaml.cs - see the README - but this new startup process allows tracking activity before initialization (solves nullrefs) and detaches the file io from startup (removes perf impact).
from csharpanalytics.
Related Issues (20)
- GetEntryAssembly vs GetExecutingAssembly HOT 2
- ASP.NET support HOT 13
- Build break because of requestUri.ShouldUsePostForRequest() HOT 1
- Exception HOT 6
- Assembly.GetEntryAssembly can be null and causes crashes. HOT 3
- Windows Phone 8.1 Support HOT 1
- Prior requests cause null exception in BaseAutoMeasurement::Request HOT 1
- Exception on Start() HOT 8
- Starting multiple instances of a WPF application at same time throws Exception in Start()
- Add a flag AutoMeasurement.Initialized HOT 6
- Make internal classes public HOT 1
- TrackEvent exchange parameters action and category HOT 1
- Allow to use GA debug URL
- MeasurementAnalyticsClient.AdjustUriBeforeRequest cuts strings with special chars HOT 2
- Setting SetOptOut before Start causes crash
- Support WPF .NET 4.0 Client Profile applications HOT 5
- At one of my testing machines I get an deserializing error
- Session start and session end time stamps registered at GA are very often too late relative to other events HOT 3
- proxy support HOT 1
- Unhandled Exception HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csharpanalytics.