Question:
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.
1 2 |
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:
1 2 |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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.
Answer:
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.