0
When trying to run my project is returned me the error:
System.Nullreferenceexception: 'Object reference not set to an instance of an object.'
I have a bank class with the manufacturer:
public bd()
{
conexao = new SqlConnection(ConfigurationManager.ConnectionStrings["conexaoBD"].ConnectionString);
conexao.Open();
}
I am using Visual Studio 2017, can anyone help me in this error? Thanks in advance.
App.config? Is this in the layer of your Asp.net? See if your App.config is going to Embedded Properties -> Build Actions
– Gabriel Coletta
is in the repository layer
– Desalex
files . config serves to configure an executable, it is not interesting to have it in a library layer, such as a repository. Your connection string must exist within the layer that the executable exists. Try to place your connectionstring inside your web.config
– Gabriel Coletta
Even in the Asp.net layer returns the same error...
– Desalex
Thank you very much Gabriel, that’s right, he has to stay inside the web.config, is that he was watching a video class only that the person put inside the app.config but it was a console project. Thanks for the help!
– Desalex
@Desalex you might be interested in: https://www.connectionstrings.com/
– Marconi