Arjun K R
Arjun K R

Reputation: 462

Google Analytics Mapping Exception

I am new to Google Analytics and trying to integrate it with my windows phone app. I followed the steps like creating a tracking ID, installing the nuget package and editing the information in analytics.xaml.

<?xml version="1.0" encoding="utf-8" ?>
<analytics xmlns="http://googleanalyticssdk.codeplex.com/ns/easytracker">
  <trackingId>UA-49305542-1</trackingId>
  <appName>MyPhoneApp</appName>
  <appVersion>1.0.0.0</appVersion>
</analytics>

I even added a tracker in my app initializer

    GoogleAnalytics.EasyTracker.GetTracker().SendView("MainPage");

When I try to execute the code in emulator, I am getting an exception. Details below

Message :

An attempt to override an existing mapping was detected for type GoogleAnalytics.Core.IPlatformInfoProvider with name "", currently mapped to type GoogleAnalytics.Core.PlatformInfoProvider, to type GoogleAnalytics.PlatformInfoProvider.

Stack Trace :

at Microsoft.Practices.Unity.UnityContainerRegistrationByConventionExtensions.RegisterTypeMappings(IUnityContainer container, Boolean overwriteExistingMappings, Type type, String name, IEnumerable1 fromTypes, Dictionary2 mappings) at Microsoft.Practices.Unity.UnityContainerRegistrationByConventionExtensions.RegisterTypes(IUnityContainer container, IEnumerable1 types, Func2 getFromTypes, Func2 getName, Func2 getLifetimeManager, Func`2 getInjectionMembers, Boolean overwriteExistingMappings) at MyPhoneApp.IocContainer.AppContainer.RegisterMySdk() at MyPhoneApp.IocContainer.AppContainer.Initialize(Frame rootFrame, DataContext dataContext) at MyPhoneApp.App.d_5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.b_0(Object state)

can someone help me in fixing this?

Upvotes: 0

Views: 198

Answers (1)

Arjun K R
Arjun K R

Reputation: 462

Unity Container provides an option to override the default behavior.

  App.Container.RegisterTypes(
            AllClasses.FromApplication(),
            WithMappings.FromMatchingInterface,
            WithName.Default,
            overwriteExistingMappings:true);

Adding the extra parameter solved the problem.

Upvotes: 1

Related Questions