I am new to desktop application development and currently building a desktop application using layered architecture (user interface, DAL, BLL).
In web development I used to store the connection string in web.config and my class library was accessing it from there. Please guide me how & where connection string should be stored for DAL in desktop application. I tried to add an app.config file in my class library and access the connection string like this:
ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString)
But it throuws an error: “Object reference not set to an instance of an object.”
Kindly guide me on this. Thanks for your support and sharing.
Yes, in a desktop application, all configuration should be in the
app.configfor that application. The class libraries used by this desktop application will get their config from thatapp.configby default.If this line throws an exception:
then it’s most likely because no
<connectionStrings>entry of name “connectionstring” exists. Check for NULL: