telemetry.TrackTrace("my text"); works on a workspace, but fails in Azure on another workspace

Copper Contributor

The following Trace (Log) is being shown on Azure:

    public static void Main(string[] args)
        // Log (Trace) test 1
        var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();        telemetry.TrackTrace("Test of ApplicationInsights.TelemetryClient() on Program.cs");

Unfortunately, when I use the same code on another namespace and project of the Solution, I got the following error on Azure:

AI (Internal): [Microsoft-ApplicationInsights-AspNetCore-StartupBootstrapper] Could not load Microsoft.AspNetCore.ApplicationInsights.HostingStartup. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.ApplicationInsights.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.ApplicationInsights.HostingStartup, Culture=neutral, PublicKeyToken=null'   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, StackCrawlMark& stackMark, IntPtr pPrivHostBinder)   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, StackCrawlMark& stackMark)   at System.Reflection.Assembly.Load(String assemblyString)   at Microsoft.ApplicationInsights.AssemblyLoader.Load(String assemblyName)   at StartupBootstrapper.Startup.TryLoadStartupAssembly(String assemblyName)

Notice I've tried to add a reference to the other project (I'm guessing that would import it's nuggets and rest of things needed), but I can't because it says:

cyclic dependencies not allowed

So I've added the same nuggets to that Project of the solution. By doing that, it compiles and I can upload to Azure. But I can see the Trace because of that error:




I'm on Visual Studio for Mac (which is actually different to Visual Studio for Windows by the way!).


What am I doing wrong?


Note for future reference: I'm also asking this question here:

0 Replies