1

After upgrading to .net core 2.2, and upgrading to the latest AWS library versions, I encounter this runtime error during initialization:

[System.InvalidOperationException] The environment variable AWS_ENABLE_ENDPOINT_DISCOVERY was not set with a boolean value.

It looks like Amazon.Runtime.EnvironmentVariableAWSEndpointDiscoveryEnabled.EnvironmentVariableAWSEndpointDiscoveryEnabled() tries to read this Environment variable.

What is strange is that it only occurs when running (in Debug mode) multiple Web API projects at the same time, and not when running a single project by itself.

Additional information:

  • .NET Core run as In Process (w/IISExpress)
  • We use it for Dynamo, Kms, CloudFront .NET libraries
  • We didn't have any issue when running it in .net core 2.0
  • AWSSDK.Core version 3.3.17.4
  • AWSSDK.Extensions.NETCore.Setup version 3.3.3
  • AWSSDK.Core version: 3.3.101.3
  • AWSSDK.Extensions.NETCore.Setup version: 3.3.100.1
Skrface
  • 1,388
  • 1
  • 12
  • 20
sebkeys
  • 86
  • 7

2 Answers2

1

The error says that the variable has not been declared. So declare it. Works for me.

Try this:

Environment.SetEnvironmentVariable("AWS_ENABLE_ENDPOINT_DISCOVERY", "false");

The complete block (in my case):

Environment.SetEnvironmentVariable("AWS_ENABLE_ENDPOINT_DISCOVERY", "false");
var opt = Configuration.GetAWSOptions();
IAmazonS3 client = opt.CreateServiceClient<IAmazonS3>();
0

If it's only you or some of your team members who see this error, check if Exception Settings -> CLR exceptions are turned on in Visual Studio.

If they are, untick the box.

Screenshot of Exception Settings panel in Visual Studio

maXer
  • 176
  • 6