0

When Running a console app packaged to a single .exe with costura.fody I appear to be unable to access my app.config resulting in the error

System.InvalidOperationException: No connection string named 'volumeEntities' could be found in the application config file. at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()

When I test in my nunit test project the app.config I added there which contains the connection string works.

I have an app.config added to the only other project in the solution. It contains the correct connection string In properties the Startup Object is set to 'Uploader.Program'

Am I missing some way of setting the project as the start up rather than the program class? How can I get the executable to find the app.config?

frogg
  • 55
  • 1
  • 10
  • 1
    Do you see a config file named `myappname.exe.config` in the output directory you are running from? – JamesFaix May 27 '20 at 16:33
  • an .exe,config is created in release, only an exe is created in release/app.publish which is due to costura.fody packaging everything together i believe – frogg May 27 '20 at 17:11
  • 1
    aaaand I'm a moron, just needed to copy the config file from release to the same folder as the .exe obviously - for some reason I thought costura would somehow package it in the exe which i was worrying I would then have to undo... Thanks @JamesFaix – frogg May 27 '20 at 17:14

1 Answers1

2

Fody costura does not package the app.config file with the executable so that you can change information in the app.config without recompiling. Copy the .exe.config to the same folder as the executable.

frogg
  • 55
  • 1
  • 10