Skip to content

MissingMethodException System.Net.Http.SocketsHttpHandler.get_MeterFactory() with 2.1.0-beta2 on .NET 8.0 #297

Closed
@kaspermarstal

Description

@kaspermarstal

Service

OpenAI

Describe the bug

The explicit dependency on System.Diagnostic.DiagnosticSource results in System.Diagnostic.DiagnosticSource.dll being copied to build directory. When the program is started, two such dlls are loaded on my machine, one from build directory and one from system directory, and I get a MissingMethodException:

'EXCEL.EXE' (CoreCLR: clr_libhost): Loaded 'C:\Users\kaspe\source\repos\cellm\src\Cellm\bin\Debug\net8.0-windows\System.Diagnostics.DiagnosticSource.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (CoreCLR: clr_libhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\9.0.0\System.Diagnostics.DiagnosticSource.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
ExcelDna.Integration Error: 1 : DnaLibrary AutoOpen Invoke Error : MissingMethodException - Method not found: 'System.Diagnostics.Metrics.IMeterFactory System.Net.Http.SocketsHttpHandler.get_MeterFactory()'.

A workaround is to explicitly exclude this dependency from being copied to the build directory in my own csproj file:

    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="9.0.0" >
      <ExcludeAssets>runtime</ExcludeAssets>
    </PackageReference>

This results in only the C:\Program Files\dotnet\shared\Microsoft.NETCore.App\9.0.0\System.Diagnostics.DiagnosticSource.dll being loaded and the program works fine.

Steps to reproduce

  1. Create a project
  2. Set net8.0-windows
  3. Add will depends on OpenAI 2.1.0-beta2
  4. Build and run

Code snippets

No response

OS

win

.NET version

8.0

Library version

2.1.0-beta2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugCategory: Something isn't working and appears to be a defect in the client library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions