ClickOnce Publish Version & Assembly Version

4 posts, 0 answers
  1. Mike
    Mike avatar
    28 posts
    Member since:
    Apr 2013

    Posted 28 Nov 2013 Link to this post

    I noticed that the analytics reports on the assembly version of the application, which in my environment we don't use as the deployment is a C# WPF app deployed via ClickOnce. 

    Is it possible to get the ClickOnce deploy version recorded as the version for the application in the analytics reports?

    I can manually set the assembly to match the ClickOnce, which I'll do for now, but it would be far neater if there was a choice of using the assembly or the deploy version.

    Thanks, Mike...
  2. Richard Flamsholt
    Admin
    Richard Flamsholt avatar
    28 posts

    Posted 28 Nov 2013 Link to this post

    Hi Mike,

    Yes, by default the monitor use the version number of the assembly, using Assembly.GetEntryAssembly() as the first choice and Assembly.GetCallingAssembly() it the former returns null.

    But it's possible to report any version number you want: simply create the monitor with settings and in those settings specify the desired version number. Like so:

            var settings = AnalyticsMonitorFactory.CreateSettings(ProductID);
            settings.Version = new Version(1, 2, 3, 4);
            var monitor = AnalyticsMonitorFactory.CreateMonitor(settings);

    I'm not certain about the specifics of retrieving the version number in a ClickOnce scenario like yours, but I'd be happy to hear about how you solve it so we can start a "best practices" for ClickOnce deployed applications.

    Regards,
    Richard Flamsholt
    Telerik
    ICENIUM MONITOR AVAILABLE FOR DOWNLOAD.
    Monitor and track applications built with Icenium at run-time. Reduce support by fixing run-time crashes as they occur, obtain user insights such as location and system configuration, find and remove application bottlenecks, and track which features are used most to help prioritize development.
    Try Icenium with EQATEC Analytics today >>
  3. Mike
    Mike avatar
    28 posts
    Member since:
    Apr 2013

    Posted 03 Dec 2013 Link to this post

    This is the code I am pretty much using now. The IAnalyticsMonitor is declared in the main view model and I also do a .Start() from here also. The ClickOnce exposes an "isNetworkDeployed" bool, so it's easy to see if you're running in ClickOnce or are deploying from a network source. I have only ever used ClickOnce, so not sure about other methods here.

    Hope this helps, Mike...


    public static IAnalyticsMonitor analyticsMonitor;
    public static IAnalyticsMonitorSettings amSettings = AnalyticsMonitorFactory.CreateSettings("XYZ");
    //...
     
        if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
        {
            appVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion;
        }
        else
        {
            appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
        }
     
        if (!Debugger.IsAttached)
        {
            amSettings.TestMode = false;
        }
        else
        {
            amSettings.TestMode = true;
        }
     
    // technically don't need to do this next statement as both amSettings.Version and appVersion are both of type "Version".  
        amSettings.Version = new Version(appVersion.Major, appVersion.Minor, appVersion.Build, appVersion.Revision);
         
          analyticsMonitor = AnalyticsMonitorFactory.CreateMonitor(amSettings);
        analyticsMonitor.Start();


              
  4. Richard Flamsholt
    Admin
    Richard Flamsholt avatar
    28 posts

    Posted 10 Dec 2013 Link to this post

    Hi Mike,

    Great, thanks!

    We'll be giving our documentation a major overhaul soon and I've added the relevant part of your snippet to be included in a section about using Analytics in a Click-Once app.

    Regards,
    Richard Flamsholt
    Telerik
    ICENIUM MONITOR AVAILABLE FOR DOWNLOAD.
    Monitor and track applications built with Icenium at run-time. Reduce support by fixing run-time crashes as they occur, obtain user insights such as location and system configuration, find and remove application bottlenecks, and track which features are used most to help prioritize development.
    Try Icenium with EQATEC Analytics today >>
Back to Top