简体   繁体   中英

How to fix configuration error 'The CodeDom provider type could not be located' and parsing error 'Could not load type' leading to each other?

I'm currently working on a project, that includes ASP.net, JS, C#, Html and etc. My project was working fine and had no problem to load whats so ever and neither had any problems running using IIS express (10.0). I added a few more classes and edited a web form, and when I tried to run the code in order to check my work, I had the 'Server Error in '/' Application. Configuration Error' thrown.

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.

Source Error:

Line 31: <system.codedom>
Line 32: <compilers>
Line 33: <compiler language="c#;cs;csharp" extension=".cs"
Line 34: type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Line 35: warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>

Source File: C:\Users\Dell\Desktop\School\מדעי המחשב\WebProject\Project\web.config Line: 33

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

when I tried searching for a solution, I've found a few, but they all led me to a "Parser error", 'Could not load type'.

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'Project.Global'.

Source Error:

Line 1:  <%@ Application Codebehind="Global.asax.cs" Inherits="Project.Global" Language="C#" %>

Source File: /global.asax Line: 1

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

No matter what method nor approach I'm trying to use in order to solve any of these problems, I always seem to get back to the second one... Could anyone please help?

It's likely because you have

<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
        <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
</system.codedom>

in your Web.config file but the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package is not installed in the project. Check your project package references to see if the package is installed. If it's not, go to Nuget Package Manager and install Microsoft.CodeDom.Providers.DotNetCompilerPlatform.

Ensure that the /bin folder is not empty. It should contain all .dll files after build

I had the project properties Build -> Output path set to bin\Debug. The DLLs were copied into this folder upon cleaning and rebuilding the solution but still I was getting this error. After changing the output path to bin\ and rebuilding the solution it worked on the localhost. Then I changed the properties to set the Build output path back to \bin\Debug\ and rebuilt the solution and it worked fine.

If you still have such problem

  1. Add NETStandard.Library nuget to your project.
  2. Add the following line to your web.config :
<system.web>
    <compilation debug="true" targetFramework="4.8">
      <assemblies>
        <!-- ADD THIS LINE BELLOW -->
        <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      </assemblies>
    </compilation>

The error means that you don't have all the dll files required for the project.

In my case I just uploading the bin folder to my hosting directory because it is not uploaded, so I uploaded bin folder manually and it worked. MA

This may be specific to me, but I was adding a webservice that was in a folder under the main application folder. I had to go into IIS and create a virtual application to this folder. I THINK that causes IIS to ignore web.config files "above" this folder and use the web.config file for this "application". Maybe that will help someone who is searching like I was. In my case I had another web service structured identically and I could not figure out why one worked and the other did not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM