Error: The controller for path ‘/’ was not found or does not implement IController.
Description: Common MVC Controller error every one faces during setting up of default Controller in Route configuration file. The reasons can be different and very difficult to find out the root cause because the Exception object wont pin point to the exact location or root cause of error. It can be due to Areas with shared layout, not using same controller name etc. etc.
Solution: Open RouteConfig.cs from App_Start check the controller name value. If you are appending “Controller” key word then just remove it. This is one of the reason, will add more in future.
controller = "Default1Controller"
remove “Controller” keyword, use just
controller = "Default1"
Also, make sure you are providing proper action view.
Error: Must declare the scalar variable “”.
Description: An SQL Server exception which occur when a local variable being used within a script, function or Stored Procedure that is not declared using the DECLARE statement.
Solution: Declare the variable using the DECLARE statement.
DECLARE @FirstName NVARCHAR(25);
Error: Object cannot be cast from DBNull to other types.
Description: An invalid cast exception, when trying to convert a nonexistent value of table column to other types.
Solution: Use DBNull.Value to validate the column having a valid value or not.
Error: The build must be stopped before the solution can be closed.
Description: When attempt to close Visual Studio solution or project while the build is running the exception windows throws up.
Solution: First stop the build or kill the process devenv.exe (if the solution got crashed) and then close the solution.
Error: Unable to connect to the Database.
Description: While trying or establishing a database connection and the connectivity to the database is not configured properly then this error occurs. More exception details as followed.
Exception Message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (-1)
- Check whether TCP/IP in SQL Server Configuration is enabled or not.
- Ping the server name from command prompt. If no reply from server, then network connection to the server should be configured or enabled.
- Using Telnet command, we can check the port is opened or not, if not open the port.
- Check whether firewall is blocking the server port.
- Check any antivirus is blocking the server.
- Check the database name, user name and password using is correct or not.
- Check the required SQL Services (SQL Server Browser etc) account are running or not.
- Check your LAN network having connectivity issues.
- Use port number along with data source. e.g server name/server name, port number.
- Try creating alias in SQL Server Configuration.
- Try to connect the database through Visual Studio.
- Try using Database Server IP address as Server Name with or without port number.
Error: Cannot have multiple items selected in a DropDownList.
Description: This error occurs when we try to select a value multiple times for a DropDownList. Let say we have multiple items getting added or inserted to the control and setting a value as true during runtime multiple times. This will confuses the control and throws an exception.
DropDownList1.Items.Add(new ListItem("one", "1"));
DropDownList1.Items.Add(new ListItem("two", "2"));
DropDownList1.Items.Selected = true;
DropDownList1.Items.Add(new ListItem("three", "3"));
DropDownList1.Items.Add(new ListItem("four", "2"));
DropDownList1.Items.Selected = true;
In above example, multiple times we are trying to set a value for dropdownlist.
Solution: Using SelectedValue or SelectedIndex properties.
DropDownList1.SelectedValue = "4";
Error: A Command with that name already exists.
Description: This error usually pops up from Visual Studio when there is a corrupted add-in or extension added into VSPackages.
Solution: Identify, remove and reinstall the extension. And run the following command Devenv.exe /ResetSkipPkgs from Visual Studio Command Prompt. /ResetSkipPkgs clears all options to skip loading added to VSPackages by users wishing to avoid loading problem VSPackages, then starts Visual Studio.
Edit: How to remove Addins from Visual Studio.
Open path – C:\Users\username\Documents\Visual Studio 2010\Addins and remove the necessary files.
Then type and run devenv /resetaddin following command from Visual Studio Command Prompt.