Skip to content

Compatibility with .NET 8 #374

@ghost

Description

Describe the bug

The AWS Tools for PowerShell cmdlets work fine in both PowerShell 5.1 and PowerShell 7.5 in Windows Terminal. However, when invoked using Devolutions Remote Desktop Manager Before Open Event using PowerShell, cmdlets throw the following error:

PS>TerminatingError(Get-SSMSession): "Method not found: 'Void Amazon.Util.Internal.InternalSDKUtils.ApplyValuesV2(!!0, System.Collections.Generic.IDictionary`2<System.String,System.Object>)'."
Get-SSMSession: 
Line |
  48 |    Get-SSMSession -Region $region -ProfileName $profileName -State Act …
     |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Method not found: 'Void Amazon.Util.Internal.InternalSDKUtils.ApplyValuesV2(!!0, System.Collections.Generic.IDictionary`2<System.String,System.Object>)'.

The cmdlet invoked really doesn't seem to matter, as Invoke-AWSSSOLogin also exhibits this same behavior. In looking at the AWS .NET SDK, I have to wonder if the issue is due to Devolutions Remote Desktop Manager requiring .NET 8, specifically here:

https://github.com/aws/aws-sdk-net/blob/main/sdk/src/Core/Amazon.Util/Internal/InternalSDKUtils.cs#L179

#if NET8_0_OR_GREATER
        public static void ApplyValuesV2<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(T target, IDictionary<string, object> propertyValues)
#else
        public static void ApplyValuesV2<T>(T target, IDictionary<string, object> propertyValues)
#endif

I don't claim to know enough about PowerShell and .NET stuff to debug further, but it seems that the declaration of ApplyValuesV2 is different if being invoked under .NET 8 or greater, and perhaps what is being passed to it by the AWS Tools for PowerShell no longer matches the declaration in the SDK?

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

AWS Tools for PowerShell cmdlets work fine in Devolutions Remote Desktop Manager

Current Behavior

cmdlets invoked under Devolutions Remote Desktop Manager throw the following error:

PS>TerminatingError(Get-SSMSession): "Method not found: 'Void Amazon.Util.Internal.InternalSDKUtils.ApplyValuesV2(!!0, System.Collections.Generic.IDictionary`2<System.String,System.Object>)'."
Get-SSMSession: 
Line |
  48 |    Get-SSMSession -Region $region -ProfileName $profileName -State Act …
     |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Method not found: 'Void Amazon.Util.Internal.InternalSDKUtils.ApplyValuesV2(!!0, System.Collections.Generic.IDictionary`2<System.String,System.Object>)'.

Reproduction Steps

  1. Install AWS Tools for PowerShell (AWS.Tools.Common should suffice).
  2. Install Devolutions Remote Desktop Manager (latest version depends upon .NET 8 SDK).
  3. Create a remote desktop connection, and create a Before Open event using PowerShell, and invoke an AWS cmdlet (Invoke-AWSSSOLogin should suffice).
  4. Attempt to connect.

In order to capture errors, I had to add the following at the beginning of the script:

Start-Transcript -Path "${Env:TEMP}\transcript.txt"
Set-PSDebug -Trace 2 | Tee-Object -FilePath "${Env:TEMP}\transcript.txt" -Append

Possible Solution

No response

Additional Information/Context

No response

AWS Tools for PowerShell version used

AWS.Tools.Common 4.1.755
AWS.Tools.SimpleSystemsManagement 4.1.755
AWS.Tools.SSO 4.1.755
AWS.Tools.SSOOIDC 4.1.755

PowerShell version used

Name                           Value
----                           -----
PSVersion                      5.1.22621.4391
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.4391
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Operating System and version

Windows 11 23H2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions