Encountering errors during the development process can be frustrating and time-consuming, especially when they are related to essential components like CodeDom providers. One such common issue developers face is the CodeDom provider type “Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider” could not be located. This article aims to explain the cause of this error and provide a clear, step-by-step solution to resolve it.


This error typically occurs in ASP.NET projects when the necessary CodeDom provider packages are missing or not correctly referenced in your project. CodeDom providers are crucial for dynamically compiling and running C# and VB code, and the absence of these can lead to compilation errors. The specific cause is often linked to the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package not being installed or configured correctly in the project.


The solution involves ensuring that the required NuGet packages are installed and properly configured in your project. Below, we outline the steps to resolve this issue.

Steps to Follow to Resolve

Step 1: Install the Required NuGet Packages

Ensure that your project includes the necessary NuGet packages. Open the NuGet Package Manager Console and run the following commands:

Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Install-Package Microsoft.Net.Compilers

Step 2: Update the Web.config File

Next, you need to update your Web.config file to reference the installed CodeDom providers. Add or update the section as shown below:


Step 3: Clean and Rebuild the Project

After making the necessary changes, clean and rebuild your project to ensure that all references are updated and the changes take effect. In Visual Studio, go to Build > Clean Solution and then Build > Rebuild Solution.

Step 4: Verify the Solution

Finally, run your project to verify that the error has been resolved. The application should now be able to locate the CodeDom provider without any issues.


By following these steps, you can resolve the CodeDom provider type “Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider” could not be located error in your ASP.NET projects. Ensuring that the appropriate packages are installed and correctly referenced in your project configuration is key to avoiding such issues. This straightforward solution helps maintain the smooth operation of your dynamic compilation tasks, enhancing your development efficiency. For more detailed troubleshooting or specific issues, consulting the official documentation or community forums can provide additional insights.

Support On Demand!