programing tip

CodeDom 공급자 유형“Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider”를 찾을 수 없습니다

itbloger 2020. 6. 21. 20:11
반응형

CodeDom 공급자 유형“Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider”를 찾을 수 없습니다


VS2015를 사용하는 WebApi 프로젝트입니다.

재현 단계 :

  1. 빈 WebApi 프로젝트 만들기
  2. 빌드 출력 경로를 "bin \"에서 "bin \ Debug \"로 변경하십시오.
  3. 운영

여기에 이미지 설명을 입력하십시오

빌드 출력 경로를 "bin \"에서 "bin \ Debug \"로 변경할 때까지 모든 것이 완벽하게 작동합니다. 실제로 "bin \"이외의 출력 경로는 작동하지 않습니다.

약간의 추가 사항은 "bin \"에 빌드를 남겨두면 다른 곳으로의 출력 경로를 갖는 것이 작동한다는 것입니다.

이 문제를 해결하기위한 솔루션을 제공하십시오. 실제 배포에 문제가있을 것 같습니다.


프로젝트에 Roslyn 참조가 있고 IIS 서버 에 배포하는 경우 많은 호스팅 제공 업체가 여전히 서버를 업그레이드하지 않아 Roslyn을 지원하지 않으므로 웹 사이트에 원치 않는 오류가 발생할 수 있습니다.

이 문제를 해결하려면 프로젝트 템플릿에서 Roslyn 컴파일러를 제거해야합니다 . Roslyn을 제거해도 코드 기능에 영향을 미치지 않아야합니다. 그것은 나와 내가 일한 다른 프로젝트 (C # 4.5.2)에서 잘 작동했습니다.

다음 단계를 수행하십시오.

  1. 아래 표시된 명령 줄을 사용하여 다음 Nuget 패키지에서 제거하십시오 ( 또는 루트 프로젝트 솔루션을 마우스 오른쪽 단추로 클릭하고 제거하여 Nuget 패키지 관리자의 GUI를 사용할 수 있음 ).

    PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
    PM> Uninstall-package Microsoft.Net.Compilers
    
  2. Web.Config 파일에서 다음 코드를 제거하고 IIS를 다시 시작하십시오 . ( 이 방법은 1 단계로 문제가 해결되지 않는 경우에만 사용하십시오. )

    <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.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=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
    


이 답변의 조언을 따르십시오. 문제를 해결하는 동안 나중에 다른 문제가 발생할 수 있습니다.

나는 같은 문제를 겪었다. 분명히 .NET 컴파일러가에로드되지 않았습니다 GAC. 내가 그것을 해결하기 위해 한 것은 다음과 같습니다.

먼저 패키지 관리자 콘솔에서 다음을 입력하십시오.

PM> Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform

이제 어떤 이유로 든 Microsoft의 훌륭한 신사들이 GAC에 설치하지 않기로 결정했습니다. 개발자 명령 프롬프트를 열고 다음을 입력하여 수동으로 수행 할 수 있습니다.

gacutil -i "C:\*PATH TO YOUR APP CODE*\bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll"

결론

Microsoft는 모든 사용자가 너겟 시스템으로 인해 가끔 버그가 발생하지 않아도 괜찮은 너겟으로 모든 작업을 수행하도록 권장합니다. 다른 솔루션에서 동일한 프로젝트를 사용하거나 실수로 그중 하나에서 사용하는 많은 너겟 중 하나를 업데이트하십시오. 운이 좋지 않은 경우 다른 솔루션을 빌드하려고 할 때의 의미를 알 수 있습니다. 반면에, GAC에 파일을 넣는 것은 사람들이 자신이 넣은 것을 잊어 버리고 새로운 환경을 설정할 때 이러한 파일을 포함하는 것을 잊어 버리기 때문에 미래의 문제를 야기 할 수 있습니다. 또 다른 가능한 해결책은 파일을 타사 dll의 중앙 폴더에 저장하는 것입니다 (컴파일러 타사를 호출하는 것이 이상하더라도). 이는 새로운 환경을 설정할 때 깨진 참조의 문제를 발생시킵니다. dll을 GAC에 설치하기로 결정한 경우 주의를 기울이고 그렇게했음을 기억하십시오. 그렇지 않은 경우 각 프로젝트에 대한 너겟을 다시 다운로드하고 그로 인한 모든 성가신 버그를 감내하십시오 (적어도 결국 아프고 GAC에 파일을 배치했을 때 발생했습니다). 두 가지 방법 모두 두통을 유발하고 문제를 일으킬 수 있습니다. 이는 어떤 문제를 다루기를 선호하는지에 대한 문제 일뿐입니다. 너겟 시스템을 사용하는 것이 좋으며, 너겟 시스템이 완전히 아프거나 더 나은 대안이 될 수있을 정도로 오랫동안 GAC를 다루지 않는 한 일반적으로 SO의 알 수없는 프로그래머보다 듣는 것이 좋습니다. 당신을 위해. 각 프로젝트에 대한 너겟을 다시 다운로드하고 그로 인한 모든 성가신 버그를 감내하십시오 (적어도 결국 아프고 GAC에 파일을 넣을 때 발생했습니다). 두 가지 방법 모두 두통을 유발하고 문제를 일으킬 수 있습니다. 이는 어떤 문제를 다루기를 선호하는지에 대한 문제 일뿐입니다. 너겟 시스템을 사용하는 것이 좋으며, 너겟 시스템이 완전히 아프거나 더 나은 대안이 될 수있을 정도로 오랫동안 GAC를 다루지 않는 한 일반적으로 SO의 알 수없는 프로그래머보다 듣는 것이 좋습니다. 당신을 위해. 각 프로젝트에 대한 너겟을 다시 다운로드하고 그로 인한 모든 성가신 버그를 감내하십시오 (적어도 결국 아프고 GAC에 파일을 넣을 때 발생했습니다). 두 가지 방법 모두 두통을 유발하고 문제를 일으킬 수 있습니다. 이는 어떤 문제를 다루기를 선호하는지에 대한 문제 일뿐입니다. 너겟 시스템을 사용하는 것이 좋으며, 너겟 시스템이 완전히 아프거나 더 나은 대안이 될 수있을 정도로 오랫동안 GAC를 다루지 않는 한 일반적으로 SO의 알 수없는 프로그래머보다 듣는 것이 좋습니다. 당신을 위해.


다음 nuget 패키지를 프로젝트에 추가하십시오- Microsoft.CodeDom.Providers.DotNetCompilerPlatform.

같은 문제가 있었다.


내 앱이 Vs2013에서 작동했지만 Vs2015로 업데이트 한 후 오류가 발생하는 것과 동일한 문제가 있습니다.

  1. Vs2015에서 프로젝트의 References 폴더를 마우스 오른쪽 버튼으로 클릭하여 NuGet Package Manager를 엽니 다.
  2. 찾아보기 탭에서 "DotNetCompilerPlatform"을 검색하고 "Microsoft.CodeDom.Providers.DotNetCompilerPlatform"lib를 설치하십시오.

오래된 스레드라는 것을 알고 있지만 DotNetCompilerPlatform.dll의 가능한 버전 문제를 지적하고 싶습니다. 전의. 업데이트 후. 새로 생성 된 Web.config 파일이 릴리스 된 web.config, 특히 system.codedom 부분과 다른지 확인하십시오. 필자의 경우 버전이 1.0.7에서 1.0.8로 변경되었습니다. 새 dll은 이미 서버에 복사되었지만 이전 web.config (일부 서버 특수 설정)는 변경하지 않았습니다.

<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>

두 줄을 업데이트하면 오류가 사라졌습니다.


재현 단계에 따르면 응용 프로그램 속성에서 출력 경로를 변경하는 것이 응용 프로그램을 만든 후 유일한 변경이라고 가정했습니다. 이 변경 사항은 Visual Studio가 MSBuild의 출력 어셈블리를 새 폴더에 넣도록 지시합니다. 그러나 런타임에 ASP.Net은 \ bin 폴더 대신이 새 폴더에서 어셈블리를로드해야한다는 생각이 없습니다.

답변 은 WebApi 응용 프로그램의 빌드 출력 디렉토리를 변경하는 방법을 보여줍니다. 해당 게시물에 표시된 동일한 오류를 얻으려면 web.config의 전체 <system.codedom> 섹션을 주석 처리해야합니다. 그런 다음 지시에 따라 출력 경로를 변경할 수 있습니다.

응용 프로그램 작업을 수행 한 후 <system.codedom> 섹션의 주석 처리를 제거 할 수 있습니다. 응용 프로그램에서 C # 6 새 구문을 전혀 사용하지 않으면 응용 프로그램에서 Microsoft.CodeDom.Providers.DotNetCompilerPlatform을 제거 할 수 있습니다. 그렇지 않으면 빌드 후 이벤트에 다음 명령 줄을 추가 할 수 있습니다.

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

새 CodeDom 공급자는 항상 \ bin에서 "\ roslyn"폴더를 찾습니다. 위의 명령은 해결 방법으로 작동하며 \ roslyn 폴더를 새 출력 폴더에서 \ bin으로 복사합니다.

그러나 실험에서 Visual Studio의 게시 도구는 출력 경로 설정에 관계없이 배포 위치의 \ bin 폴더에 출력 어셈블리를 게시했습니다. 귀하의 응용 프로그램은 여전히 ​​실제 배포에서 작동해야한다고 생각합니다.


쉬운 방법- 프로젝트> NuGet 패키지 관리 ...> 찾아보기 (탭)> 검색 입력에서 다음을 설정하십시오. Microsoft.CodeDom.Providers.DotNetCompilerPlatform

이 컴파일러를 설치 또는 업데이트하거나 제거하고 설치할 수 있습니다

DotNetCompiler 플랫폼


또 다른 가능한 해결책 :

관리자 권한으로 Visual Studio 인스턴스를 다시 시작하십시오 !

여기에 이미지 설명을 입력하십시오


제 경우에는 응용 프로그램 폴더의 권한을 변경하고 IIS_IUSRS 계정이 제거되면 이런 일이 발생했습니다. IIS_IUSRS (IIS 관리자-> YourWebApp-> 권한 편집-> IIS_IUSRS 추가)를 응용 프로그램 폴더에 다시 추가하고 작업했습니다.


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


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.


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.

ASP.NET does not search bin/debug 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>

You should update the "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" and "Microsoft.Net.Compilers" packages in your project .


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.


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 여기에 이미지 설명을 입력하십시오


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

  • In ProjectName.csproj, ensure that an <Import> tag for Microsoft.CodeDom.Providers.DotNetCompilerPlatform is present and points to the correct version.

  • In ProjectName.csproj, ensure that a <Reference> tag for Microsoft.CodeDom.Providers.DotNetCompilerPlatform is present, and points to the correct version, both in the Include attribute and the child <HintPath>.

  • In that project's web.config, ensure that the <system.codedom> tag is present, and that its child <compiler> tags have the same version in their type attribute.

For some reason, in my case an upgrade of this package from 1.0.5 to 1.0.8 caused the <Reference> tag in the.csproj to have its Include pointing to the old version 1.0.5.0 (which I had deleted after upgrading the package), but everything else was pointing to the new and correct version 1.0.8.0.


Make sure your project has fully built!

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

========== Rebuild All: 14 succeeded, 1 failed, 0 skipped =========

And open your bin folder and check to see if it's up to date.

I had a whole bunch of typescript errors that I ignored at first, forgetting that they were breaking the build and leading to there being no DLLs copied in.


Then the problem came back. I uninstalled both Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Uninstall-package Microsoft.Net.Compilers 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.


I just had the same problem and it was because I moved the project location and simply needed to recreate the virtual directory.


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.

To fix this we modified the project file to make it something like

It is not referencing any of the packages here directly referencing the environment variables.

This fixed the issue, however in our cases we don't use packages directly from "package.config" instead we have a separate folder to maintain version integrity across teams.


Go to inetmgr from start command In IIS manager console choose the application folder under Default Web Site right click on that folder then Convert to Application Run the .asmx file by Enabling It solved the problem


Check whether the BIN folder is uploaded completely or missing in the files.


Add a reference to the CppCodeProvider assembly.


Regarding this error I've tried:

  • Cleaning and rebuilding the project
  • Unloading and reloading the project
  • Modifying the Target Framework
  • Modifying the Output path
  • Adding nuggets to the GAC
  • Deleting the packages uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform uninstall-package Microsoft.Net.Compilers and installing them again.

While these all seem to be valid solutions, I was only able to generate new errors and in the end, the error seems able to display when certain references/nugets are missing.

In my case, I had recently reinstalled Microsoft Office and was referencing assemblies like Microsoft.Office.Core. The new install didn't seem to include the required packages, which made it so my solution couldn't build correctly.

I was able to solve this issue by reworking my code to the point where I didn't need to reference Microsoft.Office, but could've solved it by looking up the required packages and installing them accordingly.

Seems like an unclear error message from Visual Studio.


내 경우에는 내 웹 프로젝트가 제대로로드되지 않았고 (프로젝트를 사용할 수 없음을 나타냄) 관리자 모드에서 Visual Studio를 연 후 웹 프로젝트를 다시로드해야 모든 것이 잘 작동했습니다.


컴퓨터의 Windows 기능에서 인터넷 정보 서비스 (IIS)가 활성화되어 있는지 확인하십시오.여기에 이미지 설명을 입력하십시오

참고 URL : https://stackoverflow.com/questions/33319675/the-codedom-provider-type-microsoft-codedom-providers-dotnetcompilerplatform-cs

반응형