I have a very simple application which queries the database, gets the relevant data and displays it to the end users. I am using EntityFramework
to query my database and I've got a connection string in the app.config
file. Everything works perfectly fine. When I build the project and use the exe
from the release directory it works as expected, however if I move the exe
to another directory and try to run it I get an error message saying
No connection string named 'MyEntities' could be found in the application config file
So my question is do I have to include the app.config
file with my application exe to whoever uses it or am I missing something?
When you build your application, app.config
is copied to AppName.exe.config
in the same directory as the executable AppName.exe
.
This file needs to be copied along with your executable.
In general, you should copy all files from the output folder along with the executable. Such files may include referenced assemblies which will be needed to run the application.
If you don't want to expose this then you will have to encrypt the data or store the information elsewhere. Have a look at this for the encryption approach.
https://msdn.microsoft.com/en-us/library/89211k9b(VS.80).aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.