Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3443,7 +3443,26 @@ private void GetContainerPropertiesInternal()
//
if (RuntimeId == Guid.Empty)
{
ContainerObRoot = (string)computeSystemPropertiesType.GetProperty("ObRoot").GetValue(computeSystemPropertiesHandle);
// Since Hyper-V changed this from a property to a field, we can optimize for newest Windows to see if it's a field,
// otherwise we fall back to old code to be compatible with older versions of Windows
var obRootFieldInfo = computeSystemPropertiesType.GetField("ObRoot");
if (obRootFieldInfo != null)
{
ContainerObRoot = obRootFieldInfo.GetValue(computeSystemPropertiesHandle) as string;
}
else
{
var obRootPropertyInfo = computeSystemPropertiesType.GetProperty("ObRoot");
if (obRootPropertyInfo != null)
{
ContainerObRoot = obRootPropertyInfo.GetValue(computeSystemPropertiesHandle) as string;
}
}

if (ContainerObRoot == null)
{
throw new PSInvalidOperationException(RemotingErrorIdStrings.CannotGetHostInteropTypes);
}
}
}
}
Expand Down