Xamarin linker error with AWSSDK

2019-09-18 23:12发布

问题:

I have a Xamarin forms mobile project (Android and iOS).

When I try to install the AWSSDK.S3 to access Amazon services, I get the following linker error when trying to build iOS:

Failed to resolve "System.Void Amazon.Runtime.Internal.Util.AESEncryptionPutObjectStream::.ctor(System.IO.Stream,System.Byte[],System.Byte[])" reference from "AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604"

..Android build has a similar error.

I have the following libraries installed:

AWSSDK.S3 v3.1.1.1 AWSSDK.Core v3.3.4 AWSSDK.SecurityToken v3.3.0.2 AWSSDK.CognitolIdenity v3.3.0.2 AWSSDK.CognitoIdentityProvider v3.3.1.2 PCLCrypto v2.0.147 PCLStorage v1.0.2

the only code in my project is:

 var amazonClient = new AmazonS3Client();

Any ideas?

回答1:

possible (bad) workaround that seems to work:

change in Linker Options/Linker behavior:

to: Don't link

instead of: Link SDK Assemblies only



回答2:

The answer turns out to be found here:

Xamarin Forms IOS Failed to load assembly System.Net.Http.Primitive

even though its a different assembly error, the fix is the same:

  • update all the AWS.Core to the latest version: v3.3.6 in my case
  • install Microsoft.Bcl.Build v1.0.21
  • install Microsoft.Net.Http v2.2.29


回答3:

Rolling back to AWSSDK.S3 V3.1.10 worked for me, done using the NuGet manager in Visual Studio. =)