I have created windows service in .net core using microsoft.extensions.hosting.windowsservices.5.0.1 package .
Also i have created websocket server using microsoft.aspnetcore.websockets.2.2.1 package . in different library
When i am trying to start websocket server from windows service , it is causing runtime exception.
Microsoft.AspNetCore.Server.Kestrel[0]
Heartbeat.OnHeartbeat
System.TypeLoadException: Could not load type 'Microsoft.Extensions.Primitives.InplaceStringBuilder' from assembly 'Microsoft.Extensions.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at Microsoft.Net.Http.Headers.DateTimeFormatter.ToRfc1123String(DateTimeOffset dateTime, Boolean quoted)
at Microsoft.Net.Http.Headers.HeaderUtilities.FormatDate(DateTimeOffset dateTime, Boolean quoted)
at Microsoft.Net.Http.Headers.HeaderUtilities.FormatDate(DateTimeOffset dateTime)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.DateHeaderValueManager.SetDateValues(DateTimeOffset value)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.DateHeaderValueManager.OnHeartbeat(DateTimeOffset now)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.Heartbeat.OnHeartbeat()
Rootcause: Both the packages are having Microsoft.Extensions.Primitives.dll which is giving conflict so while compiling in bin directory only higher version is retained so websocket server is giving the above mentioned error.
Note :
Microsoft.Extensions.Primitives.dll 5.0 version in windows service
Microsoft.Extensions.Primitives.dll 2.21 version in websocket server .
Can someone help me in this , Not sure how to resolve this issue.