1

我正在尝试在我的 Windows 商店应用程序中使用 Google Analytics,但我遇到了异常。我对这些东西完全陌生。请帮我解决这个问题。

NuGet 包:GoogleAnalyticsSDK

例外:

 `System.AggregateException was unhandled by user code HResult=-2146233088
  Message=One or more errors occurred.
  Source=mscorlib
  StackTrace:
       at System.Threading.Tasks.Task.ThrowIfExceptional
      (BooleanincludeTaskCanceledExceptions)
       at System.Threading.Tasks.Task.Wait
      (Int32 millisecondsTimeout, CancellationToken cancellationToken)
       at System.Threading.Tasks.Task.Wait()
       at GoogleAnalytics.EasyTracker.InitConfig(Uri configPath)
       at GoogleAnalytics.EasyTracker.SetContext(Application ctx)
       at GoogleAnalytics.EasyTracker.GetTracker()
       at HelloWorld.MainPage..ctor()
       at    HelloWorld.HelloWorld_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
       at HelloWorld.HelloWorld_XamlTypeInfo.XamlUserType.ActivateInstance()
  InnerException: System.Xml.XmlException
       HResult=-2146232000
       Message='Text' is an invalid XmlNodeType. Line 33, position 29.
       Source=System.Xml
       LineNumber=33
       LinePosition=29
       StackTrace:
            at System.Xml.XmlReader.ReadEndElement()
            at GoogleAnalytics.EasyTrackerConfig.LoadConfigXml(XmlReader reader)
            at GoogleAnalytics.EasyTrackerConfig.Load(XmlReader reader)
            at GoogleAnalytics.EasyTracker.InitConfig(XmlReader reader)
            at GoogleAnalytics.EasyTracker.<InitConfig>b__0(Task`1 t)
            at `System.Threading.Tasks.ContinuationTaskFromResultTask1.InnerInvoke()`
               ` at System.Threading.Tasks.Task.Execute()
       InnerException:{"'Text' is an invalid XmlNodeType. Line 33, position 29."}`

这是我在其中使用分析的 C# 代码。主页上有 3 个按钮,我只是在检查应用程序是否使用谷歌分析平台报告统计信息。

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace HelloWorld
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            string a = "Main";
             GoogleAnalytics.EasyTracker.GetTracker().SendView(a);

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            GoogleAnalytics.EasyTracker.GetTracker().SendView("Button1");

        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            GoogleAnalytics.EasyTracker.GetTracker().SendView("Button2");
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            GoogleAnalytics.EasyTracker.GetTracker().SendView("Button3");
        }
    }
}
4

0 回答 0