alpacahq/alpaca-trade-api-csharp

Could not load file or assembly 'System.Memory' on Windows Server 2022 when calling AlpacaBroker.__PlaceOrderAsync

rshahrabani opened this issue · 0 comments

Is there an existing issue for this?

  • I have searched the existing issues

What is your question?

On our production server, we get the following error and stack trace when attempting to call AlpacaBroker.__PlaceOrderAsync. The stack trace has been pruned to show the most relevant details.

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at System.Net.Http.WinHttpResponseParser.CreateResponseMessage(WinHttpRequestState state, DecompressionMethods manuallyProcessedDecompressionMethods)
   at System.Net.Http.WinHttpHandler.<StartRequestAsync>d__122.MoveNext()
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at **Alpaca.Markets.ThrottleParameters**.CustomHttpHandler.<sendAsyncWithTimeout>d__4.MoveNext()

The same code works on our development machine, which is a Windows 11 desktop. The version of System.Memory.dll used on the server is 4.6.28619.01.

What can be causing this issue and how can we resolve it?