简体   繁体   中英

The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider" could not be located

It's a WebApi project using VS2015.

  1. <\/li>
  2. <\/li>
  3. <\/li><\/ol>

    在此处输入图像描述<\/a>

    Everything is working perfectly until I changed Build Output path from "bin\\" to "bin\\Debug\\" In fact, any Output path other than "bin\\" won't work.

    I guess that'll cost problem on actual deployment.

If your project has Roslyn references<\/strong> and you are deploying it on an IIS server<\/strong> , you might get unwanted errors on the website as many hosting providers still have not upgraded their servers and hence do not support Roslyn.

Removing Roslyn shouldn't affect your code's functionality. It worked fine for me and some other projects (C# 4.5.2) on which I worked.

  1. ( Use this method only if step 1 doesn't solve your problem.<\/em> )

Be careful of following this answer's advice.<\/strong> While it solves the problem at hand, it might cause different problems at a later date.<\/strong>

<\/blockquote>

Apparently the .NET compiler was not loaded to the GAC<\/code> . What I did to solve it was:

 You can do it manually by opening the Developer Command Prompt and typing:

<\/h2>

Microsoft try to encourage everyone to do everything with nugets which could be fine without the occasional bugs you run into with the nuget system. Try to use the same project on different solutions, accidentally (or not) update one of the many nugets it uses on one of them, and if you are unlucky you'll see what I mean when you try to build the other solution. On the other hand, putting files in the GAC can also cause future problems since people tend to forget what they put there and then when setting up new environments they forget to include these files. Another possible solution is to put the files in a central folder for 3rd party dlls (even though it's strange to call the compiler 3rd party), which creates problems of broken references when setting up new environments. If you decide to install the dll to the GAC, use caution and remember that you did so. If you don't, download the nuget for each project again and bear all the annoying bugs being caused by it (at least used to happen when I finally got sick of it and just placed the files in the GAC). Both approaches might give you headaches and create problems, it's just a question of which problems you prefer to deal with. Microsoft recommends to use the nuget system, and generally, it's better to listen to them than to an unknown programmer in SO, unless you are completely sick of the nuget system and used to deal with the GAC long enough for it to be a better alternative for you.

"

Just add the next nuget package to your project - Microsoft.CodeDom.Providers.DotNetCompilerPlatform .

Had the same problem.

I have the same problem that my app worked in Vs2013 but getting the error after updating to Vs2015.

  1. <\/li>
  2. <\/li><\/ol>"

I know it's an old thread, but I'd like to point the possible version issue of DotNetCompilerPlatform.dll, f. ex. after an update. Please check, if the new generated Web.config file is different as your released web.config, in particular the system.codedom part. In my case it was the version change from 1.0.7 to 1.0.8. The new dll had been already copied to the server, but I didn't change the old web.config (with some server special settings):

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

After I update the two lines, the error disappeared.

Another possible solution:<\/strong>

According to your repro steps, I assumed that changing the output path in the application's property was your only change after you created the application. The only thing this change does is that it tells Visual Studio to put the output assemblies of MSBuild into the new folder. At runtime, however, ASP.Net wouldn't have any idea that it should load assemblies from this new folder instead of the \\bin folder.

To get the exact same error showed in that post, you need to comment out the entire <system.codedom> section in web.config. And then you can follow the instructions to change the output path.

If you don't use C# 6 new syntax in your application at all you can uninstall the Microsoft.CodeDom.Providers.DotNetCompilerPlatform from you application; otherwise, you may want to add the following command line in your post-build event,

xcopy /Q /Y "$(TargetDir)roslyn\*.*" "$(TargetDir)..\roslyn\"

Easy way - Project > Manage NuGet Packages... > Browse(tab) > in search input set this: Microsoft.CodeDom.Providers.DotNetCompilerPlatform

You can install or update or uninstall and install this compiler

点网编译器平台

In my case, this happened when i change the permission of application folder and account IIS_IUSRS has been removed. After i re-added IIS_IUSRS (IIS Manager-> YourWebApp -> Edit Permission -> Add IIS_IUSRS) to the application folder and its worked.

"

It stopped after publishing on the production server. The reason why it showed me this error was because it was deployed to a sub folder. In IIS i clicked right on the subfolder and excuted "Convert to application" and after this it worked.

Here's how I resolved it:

  1. Deleted the bin folder in the project directory.
  2. Click on Build Solution . In VS2017(Run as Admin) > Build > Build Solution .

Then the problem came back. I uninstalled both Microsoft.CodeDom.Providers.DotNetCompilerPlatform<\/code> and Uninstall-package Microsoft.Net.Compilers<\/code> but no help. Then installed - no help. Cleaned project and built no help. Restarted server no help.Then I noticed the project needed not the latest one which is currently 1.0.5 but 1.0.3 as that was the error could not load the 1.0.3 version. So I installed that dll version instead and now it works.

"

如果您使用的是 git,您可能会忽略提交中的 .dll

ASP.NET does not search bin\/debug<\/code> or any subfolder under bin for assemblies like other types of applications do. You can instruct the runtime to look in a different place using the following configuration:

<configuration>
   <runtime>   
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="bin;bin\Debug;bin\Release"/>
      </assemblyBinding>
   </runtime>   
</configuration>

I had a number of projects in the solution and the web project (problem giving this error) was not set as the StartUp project. I set this web project as the StartUp project, and clicked on the menu item "Debug"->"Start Debugging" and it worked. I stopped debugging and then tried it again and now it's back working. Weird.

just uninstall the package from package manager console from command below

PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform

PM> Uninstall-package Microsoft.Net.Compilers

and then install it again from nuget manager在此处输入图像描述

您应该更新项目中的“Microsoft.CodeDom.Providers.DotNetCompilerPlatform”和“Microsoft.Net.Compilers”包。

"

In my case, I got the error when I had my Web Application in 4.5.2 and the referenced class libaries in 4.6.1. When I updated the Web Application to 4.5.2 version the error went away.

I was getting this error because my application pool user was set to ApplicationPoolIdentity. I changed it to a user\/service account that has access to the folder and the error went away.

"

Here are my findings. I also faced this problem today's morning. I just added my current user to application pool on which application was running.

Steps:

  1. Open IIS

  2. Click on application pool

  3. Select your application pool on which you are getting problem

  4. Right Click -> advanced settings

  5. Click on three dot icon beside the identiy

  6. Now select custom account

  7. Give your PC user name and Password

  8. Save

Refresh your application.. and it will start working. There was some security issue for accessing dll.

If you have recently installed or updated the Microsoft.CodeDom.Providers.DotNetCompilerPlatform<\/code> package, double-check that the versions of that package referenced in your project point to the correct, and same, version of that package:

  • 5<\/strong> .0 (which I had deleted after upgrading the package), but everything else was pointing to the new and correct version 1.0. 8<\/strong> .0.

Make sure your project has fully built!<\/h3>

Click on 'Output' tab and make sure you don't have something like:

从启动命令转到 inetmgr 在 IIS 管理器控制台中,选择默认网站下的应用程序文件夹,右键单击该文件夹,然后转换为应用程序通过启用运行 .asmx 文件它解决了问题

"

添加对 CppCodeProvider 程序集的引用。

在我的情况下,我的 Web 项目没有正确加载(它显示项目不可用),然后我不得不在以管理员模式打开我的 Visual Studio 后重新加载我的 Web 项目,然后一切正常。

"

If you have been working on a project and this just now popped up as an error. REBOOT your computer (or server in my case) this fixed the issue for me.

"

我只是遇到了同样的问题,这是因为我移动了项目位置,只需要重新创建虚拟目录。

"

The exception that we ran into was not on the local but on the remote server, the Azure CI was reading it from the packages folder but the compiler versions mentioned above were not found.

检查文件中的BIN文件夹是否完整上传或丢失。

Regarding this error I've tried:

If you see this probably you are building in release mode . For production you should publish instead of building in release mode. For local development build in debug mode.

In our case we are using ToroiseSVN and it seems by default the bin folder is not added to the sourcecontrol. So when updating the website on the production server the bin folder was not added to it, thus resulting in this exception.

To add the bin folder to SVN go to the folder on the hdd and find the bin folder. Right click it and select TortoiseSVN --> Add

Now update the repository to include the newly added files and update the production server next. All should be well now.

Ensure Internet Information Services(IIS) is enabled in Windows features on your machine. 在此处输入图片说明

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