Could not load file or assembly 'Microsoft.AppCenter.Analytics, Version=0.0.0.0, Culture=neutral ...

ledien 1 Reputation point
2019-12-03T09:16:46.557+00:00

I have project UWP by c++ name: TestAppCenter and " Window Runtime Component" by C# name :CoreRuntime .I have added "App center SDK" by install Microsoft.AppCenter.Analytics and Microsoft.AppCenter.Crashes packages for "CoreRuntime" .

alt text

In project UWP (TestAppCenter ) i call to function in CoreRuntime to init app center like :

App::App()  
{  
    InitializeComponent();  
    Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);  
	//CoreRuntime::Class1 ^ob = ref new Class1();  
	//ob->InitAppCenter();  
	CoreRuntime::Class1::InitAppCenter();  
}  

But it show error :

**WinRT information: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AppCenter.Analytics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified**.  

Here is my source test :

//Class1.cs  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;  
using Microsoft.AppCenter;  
using Microsoft.AppCenter.Analytics;  
using Microsoft.AppCenter.Crashes;  
namespace CoreRuntime  
{  
    public sealed class Class1  
    {  
        public static void InitAppCenter()  
        {  
            AppCenter.Start("afc4f213-f02e-4f74-ae42-6386100bdaf8", typeof(Analytics), typeof(Crashes));  
  
        }  
    }  
}  
  

//App.xaml.cpp  
App::App()  
{  
    InitializeComponent();  
    Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);  
	//CoreRuntime::Class1 ^ob = ref new Class1();  
	//ob->InitAppCenter();  
	CoreRuntime::Class1::InitAppCenter();//<--- call here.  
}      
 

I try call this function with static method , instance object. Could you please show me why it generate this error ? And solution for this .
Thank!!

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. AlexanderSklar 11 Reputation points
    2020-04-22T01:07:55.16+00:00

    @ledien We've identified a fix and we're pursuing a public doc update.
    In the meantime here's how to consume a C# WinRT component from C++/WinRT

    0 comments No comments