Closed
Description
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
- Create a project
- Set net8.0-windows
- Add will depends on OpenAI 2.1.0-beta2
- Build and run
Code snippets
No response
OS
win
.NET version
8.0
Library version
2.1.0-beta2