Error message 1
Object reference is not set to an instance of the object.
Error Message:
[Problem Analysis]: Open the App.config file, check the string in the name node and the current brackets is the same, the comparison found, not the same, more than one S. Remember, C# reads the name in brackets used in the node, and the configuration file node configuration name must be consistent!
Solution
[problem-solving] remove “s” and run it.
[other Error] 1: some friends don’t pay attention to this situation that you add spaces in the string will also lead to this problem, such as the following:
Spaces must be removed. You cannot add any spaces in the configuration file.
[other Error] 2: if the node position is written incorrectly, the above error will also occur. For example, in the screenshot below, the node should be written to the arrow position.
[other Error] 3: If the App.config configuration file is not added, or the App.config file is not placed in the project launchable project directory, the above error will also occur. For example, the following is wrong:
The following green part is the project’s startable items, App.config file must be put here to work.
[Other Error] 4: modified the name of the configuration file, the configuration file requirements must be the default App.config to work, if you modify the file name, there will also be errors, such as the following is not allowed: the case of.
Error message 2
The type initial value setting item of “ThreeLayer.DAL.SQLHelper” raises an exception.
Error Message:
The problem is that as long as the prompt “SQLHelper’s type initial setting item raises an exception”. Generally, it is a configuration file problem, because we use App.config configuration file to save the data connection string. For beginners, because they can’t understand this error, so they don’t know where to start, here please remember the following troubleshooting methods.
Solution
[Solution 1] The configuration file node is written wrong
Originally this place node name is also the above is less than an s, change to the following can be: [Solution 2] configuration file App.config file if you change the name, not placed in the “startable project” root directory.
[Solution 2] configuration file App.config file if the name is modified, not put into the “startable project” root directory, some VS versions will also appear the above error. (This is the same as the solution to error 1)
Summary
According to the above method, you can perfectly solve the common problem of getting the connection string through App.config. I hope today’s content can help you.
Read More:
- The authentication server Configurate NoClassDefFoundError Error (store client information in a JDBC-based database)
- How to Solve Clickhouse restart error: Cannot obtain value of path from config file…
- [Solved] Redis Startup Error: FATAL CONFIG FILE ERROR
- Intellij IDEA jetty-jmx.xml Error:Duplicate config file paths found
- [Solved] Vite Project jenkins Auto Package Error: failed to load config from ../vite.config.js You installed esbuild on
- [Solved] Spring cloud config server can’t parse the YML file of the remote warehouse, and it will also report an error
- [Solved] throw new Error(“‘output.filename’ is required, either in config file or as –output-filename”);
- [Solved] GBase 8a MPP Database sftp Loading Large File Error
- [Solved] XML file configuration database connection information logical symbol error
- [Solved] Unexpected error while saving file: xxx.ipynb database or disk is full
- JSP web.xml file header web app error [How to Solve]
- [Solved] Android app development version update failed, Android – error: task execution failed ‘: app: com
- Android studio configurate intent-filter and compile error [Solved]
- [Solved] Android Room: Database Common Error ‘missing database’
- Kafka configurate broker mapping error: discovered coordinator XXX rack: null
- [Solved] ZooKeeper Configurate Error: Error contacting service. It is probably not running.
- Mybatis Connect Database Error: Error querying database. Cause: java.sql.SQLException: The server time zone value..
- ArchLinux starts error after modifying MariaDB database path Can’t create test file /xxxxx/xxxxx-test
- Creating test database for alias ‘postgres’… Got an error creating the test database: permission
- flask init-db Error: Error: Could not locate a Flask application. Use the ‘flask –app’ option, ‘FLASK_APP’ environment variable, or a ‘wsgi.py’ or ‘app.py’ file in the current directory.