AWS sdk for C #, where to put the App.config file?


So I have a C# console application that uploads files to s3 storage.

It works fine when I debug it from inside Visual Studio, however, when I build the .exe and run it off my server, I get errors saying that it couldn't find the Access Key inside the App.config file.

System.ArgumentException: Access Key could not be found.  Add an appsetting to your App.config with the name AWSAccessKey with a value of your access key.

And also:

Amazon.Runtime.AmazonServiceException: Unable to reach credentials server

The second error is might be caused by the first.

I have my App.config file in the same directory as the .exe I'm running, but that doesn't help.

What else do I have to do?

Here's my App.config file:

<?xml version="1.0" encoding="utf-8"?>
    <add key="AWSAccessKey" value="key"/>
    <add key="AWSSecretKey" value="secret"/>
    <add key="AWSRegion" value="us-west-2" />
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />

The build action for this file is "Embedded Resource" I've also tried changing it to "Content" and that didn't help.

Some things that may or may not be relevant:

I'm using ILMerge to merge the AWSSDK.dll (among others) into the exe, then I run that file off of an Amazon EC2 instance through the command line.

When you look in your "bin" directory, the .config file should be named yourprogram.exe.config. It won't find the configuration values otherwise, and it should be a content file, not an embedded resource. The .config file must always be present and in the same directory as the EXE.