Method not found: 'Serilog.Context.LogContext.Push(Serilog.Core.ILogEventEnricher[])'

  • Objective:
    I’m using the speckle .net sdk to send data to my local speckle server.

  • Issue:
    When the compiler hits this line of code, an exception is thrown with the information shown below.

Project projectFound = await SpeckleAuthClient.Shared.Client.Project.GetWithModels(SpeckleProjectId);
if (projectFound == null) throw new Exception($"Speckle Project not found with id: {SpeckleProjectId}");

I’ve come across with the following link:

and I will explore if removing other revit add-ins fix the issue to find the one that conflicts with the speckleCore2. If that’s the case, how can we make all add-in work together using different versions of serilog?

  • Example:

Updates, after disabling all other add-in we still encountering the same issue:


Do you have any idea of what it could be the root cause of the issue?

These are the packages version we are using:

<Reference Include="GraphQL.Primitives, Version=6.1.0.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\GraphQL.Primitives.6.1.0\lib\netstandard2.0\GraphQL.Primitives.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
      <HintPath>packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </Reference>
    <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
      <HintPath>packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
    </Reference>
    <Reference Include="Objects, Version=2.21.3.16520, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\Speckle.Objects.2.21.3\lib\netstandard2.0\Objects.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Objects.Converter.Revit2024, Version=2.21.3.16520, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\Speckle.Objects.Converter.Revit2024.2.21.3\lib\netstandard2.0\Objects.Converter.Revit2024.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Objects.ConverterDxf, Version=2.21.3.16520, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\Objects.ConverterDxf.2.21.3\lib\netstandard2.0\Objects.ConverterDxf.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="RevitAPI, Version=24.0.0.0, Culture=neutral, processorArchitecture=AMD64">
      <HintPath>packages\Speckle.Revit.API.2024.0.0\lib\net48\RevitAPI.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="RevitAPIUI, Version=24.0.0.0, Culture=neutral, processorArchitecture=AMD64">
      <HintPath>packages\Speckle.Revit.API.2024.0.0\lib\net48\RevitAPIUI.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Speckle.netDxf, Version=3.0.2.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\Speckle.netDxf.3.0.2\lib\net45\Speckle.netDxf.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="SpeckleCore2, Version=2.21.3.16520, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>packages\Speckle.Core.2.21.3\lib\netstandard2.0\SpeckleCore2.dll</HintPath>
      <Private>False</Private>
    </Reference>

Hi @Miguel_Gutierrez

I suspect somehow the wrong version of serilog is being loaded.
I would suggest you try and find the version number of serilog that is loaded. See this stack overflow post on how you can find this out https://stackoverflow.com/questions/458362/how-do-i-list-all-loaded-assemblies

Speckle.Core 2.21.3 is expecting Serilog version 2.12.0 (netstandard2.0)

If you see a serilog already loaded with a different assembly or .NET version (e.g NET8), then you need to find the conflicting plugin. Finding the path of the serilog DLL would be a good start, either by debugging the assembly object, or by searching your system. There are several paths that Revit loads plugins from.

If you don’t see any Serilog loaded, then it could be that your csproj has miscongigured dependencies. I can make a few suggestions if you find this to be the case.
You should ensure you see it in your bin output folder.

1 Like

Hi @Jedd so far I’ve been tracking the following serilog packages:

Serilog.Sinks.Seq.5.2.2, from the .net4.5 folder
Serilog.Sinks.Console.4.1.0 , from the .net 4.5 folder as well

After loading the second one, I’m encountering a different issue:

image

The original issue came when loading all dlls from the .net2standard folder. Now I’ve tried again using the .net 4.5 folder since my project target is .netframework4.8 for revit add-in development.

By the way, It’s worthy knowing that I’m working on a .netframework revit add-in project that reference a shared project. Thus, all the dependencies are referenced through this command:

        AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
        {
            string currentAssemblyLoc = Assembly.GetExecutingAssembly().Location;
            string tesseraAssemblyLoc = Path.GetDirectoryName(currentAssemblyLoc) ?? "";
            string dependencyDll = new AssemblyName(args.Name).Name + ".dll";
            string assemblyPath = Path.Combine(tesseraAssemblyLoc, "LPA-Dependencies", dependencyDll);
            return File.Exists(assemblyPath) ? Assembly.LoadFrom(assemblyPath) : null;
        };

In summary, currently I’m stuck after loading the Serilog.Sinks.Console.4.1.0 package when running this line of code:
Project projectFound = await SpeckleAuthClient.Shared.Client.Project.GetWithModels(SpeckleProjectId);

I was working in a new machine and the issue was fixed after installing the speckle manager app. After doing so, it seems that the app sets up the appropriate serilog version