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

advertisements

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"?>
<configuration>
  <appSettings>
    <add key="AWSAccessKey" value="key"/>
    <add key="AWSSecretKey" value="secret"/>
    <add key="AWSRegion" value="us-west-2" />
  </appSettings>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

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.