Azure / hpcpack

The repo to track public issues for Microsoft HPC Pack product.
MIT License
30 stars 12 forks source link

HPC.SDK 6.3.8187-beta will not connect on .NET 8.0+ #53

Closed ventrebd closed 1 month ago

ventrebd commented 1 month ago

Problem Description

Microsoft.HPC.SDK 6.3.8187-beta in a .NET 8.0 application fails to connect to the server -- the scheduler.Connect call throws a System.AggregateException with the message "Could not register with the server. Try again later."

The core issue turns out to be the use of BinaryFormatter deep inside the HPC code. The deserializer has been removed & now throws "System.NotSupportedException" in the EventListener.cs source file. Microsoft docs at:

I followed the not-recommended methods in the above documentation to add the unsupported System.Runtime.Serialization.Formatters NuGet package and <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization> property to my project. Unfortunately, this is not a suitable long-term solution.

Steps to Reproduce

In a .NET 8.0 console application:

  1. Add Microsoft.HPC.SDK 6.3.8187-beta as a NuGet package
  2. Add the following to a C# file
using (Microsoft.Hpc.Scheduler.Scheduler sched = new Microsoft.Hpc.Scheduler.Scheduler()) {
    sched.Connect(schedulerName);
}

Expected Results

Program should execute with no errors

Actual Results

Connect call throws a "System.AggregateException" with the message "Could not register with the server. Try again later." The debug output in Visual Studio reports many "System.NotSupportedException" errors in System.Runtime.Serialization.Formatters.dll and Microsoft.Hpc.Scheduler.Store.dll

Work-around (unsafe!)

  1. Add System.Runtime.Serialization.Formatters NuGet package (I used 9.0.0-rc.2.24473.5)
  2. Add <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization> within <PropertyGroup> of the csproj file.
YutongSun commented 1 month ago

@ventrebd , good catch, there is a known issue https://github.com/Azure/hpcpack/issues/39. We need to use BinaryFormatter for backward compatibility and will migrate off it in the next major release.

ventrebd commented 1 month ago

Excellent, thanks. Not sure why that issue didn't come up in my searches (sure would have saved some time!). I will close this one.