Home > Microsoft Visual C

How to fix common Microsoft Visual C++ error codes?

Alton Alexander
By Alton AlexanderUpdated on June 4th, 2022

Error code C2146 is a common Microsoft Visual C error code. This error code happens when the compiler is unable to find a matching token. This can happen when the wrong character is used, or when the character is missing altogether.

1. Try reinstalling the program

  1. Go to the Microsoft website and type in "Visual C reinstall" into the search bar.
  2. On the Microsoft website, click on the link that says "Visual C reinstall: step-by-step instructions."
  3. Read the instructions carefully and follow them step-by-step.
  4. When you have finished reinstalling the program, try running it again. If the problem has not been fixed, go to step 5.
  5. If the problem has been fixed, then you can delete the old program files and install the new program files.

2. Make sure that all dependencies are installed

  1. Open a command prompt and change directory to the folder where the project files are located.
  2. Execute the following command to install the Microsoft Visual C++ 2005 Redistributable package: msiexec /package {RedistributablePackagePath}
  3. Execute the following command to install the Microsoft Visual C++ 2008 Redistributable package: msiexec /package {RedistributablePackagePath}
  4. If the project requires the Microsoft Visual C++ 2010 Redistributable package, execute the following command: msiexec /package {RedistributablePackagePath}
  5. Close the command prompt.
  6. Open the project file in a text editor.
  7. Locate the following line of code: #include "stdafx.h"
  8. Change the line to include the following path: #include "Microsoft.VC80.CRT.h"
  9. Save the file.
  10. Double-click the project to launch it.
  11. If the project fails to compile, verify that all the required dependencies are installed.
  12. If the project still fails to compile, verify that the Visual C++ libraries are installed.
  13. If the project still fails to compile, verify that the project files are located in the correct directory.
  14. Verify that the project files are located in the correct directory and that the required dependencies are installed.
  15. If the project still fails to compile, verify that the project files are located in the correct directory and that the Microsoft Visual C++ 2010 Redistributable package is installed.

3. Try running the program in compatibility mode

To run the program in compatibility mode, follow these steps:

  1. On your computer, open the folder where the program is located.
  2. Double-click the program.
  3. If the program asks if you want to run it in compatibility mode, click Yes.
  4. If the program crashes or does not work correctly, try running it in compatibility mode again.

4. Make sure that you have the latest service pack installed

  1. Go to the Microsoft website and type in “service pack” in the search bar.
  2. Click on the “See All Results” link and then select the “Service Packs” option.
  3. Look for the “Service Pack for Microsoft Visual C++ 2005” and click on the link to download the service pack.
  4. Run the service pack installer and follow the on-screen instructions.
  5. After the installation is complete, restart your computer.
  6. Check for any new error messages that may have occurred as a result of the service pack installation.
  7. If the problem has not been resolved, go back to the Microsoft website and type in “Visual C++” in the search bar.
  8. Select the “Visual C++” option from the list of results and click on the link to download the latest service pack.
  9. Run the service pack installer and follow the on-screen instructions.
  10. After the installation is complete, restart your computer.
  11. Check for any new error messages that may have occurred as a result of the service pack installation.
  12. If the problem has not been resolved, go back to the Microsoft website and type in “Visual C++” in the search bar.
  13. Select the “Visual C++” option from the list of results and click on the link to download the latest service pack.
  14. Run the service pack installer and follow the on-screen instructions.
  15. After the installation is complete, restart your computer.
  16. Check for any new error messages that may have occurred as a result of the service pack installation.
  17. If the problem has not been resolved, go back to the Microsoft website and type in “Visual C++” in the search bar.
  18. Select the “Visual C++” option from the list of results and click on the link to download the latest service pack.
  19. Run the service pack installer and follow the on-screen instructions.
  20. After the installation is complete, restart your computer.

5. Try repairing the installation of Microsoft Visual C

If you are experiencing a Microsoft Visual C error code, you can try repairing the installation. Some common repair steps are as follows:

  1. Try uninstalling and reinstalling Microsoft Visual C.
  2. Try running Microsoft Visual C as an administrator.
  3. Try repairing Microsoft Visual C using the Microsoft Visual C Installer.

Still not working? maybe try one of these options:

  1. Try using a different compiler.
  2. Try uninstalling and then reinstalling Microsoft Visual C.
  3. Try running the program as an administrator.