IIS Add Managed Module error after moving from Windows Server 2016 to Windows Server 2022

chribonn 21 Reputation points
2022-06-11T08:43:26.38+00:00

I updated a VM running Windows Server 2016 to Windows Server 2022.

On Windows Server 2016 I was running ASP.NET 4.7.

After upgrading I get the error below if there is a C-Sharp program (I tested with a Hello, World! script) and I click the Add Managed Module option in IIS.

There was an error while performing this operation.  
  
Details:  
  
Cannot execute a program. The command being executed was 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe' /noconfig /fullpaths  
@"C:Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\<number>\<number>.cmdline".  

210436-hhjz7.png

The C-Sharp Compile (csc.exe) is present in the directory.

Any idea how I can diagnose the issue and solve it please?

Internet Information Services
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,243 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Yurong Dai-MSFT 2,771 Reputation points Microsoft Vendor
    2022-06-13T06:10:09.943+00:00

    Hi @chribonn ,

    Since the .NET 4.5 version, Roslyn compilation is the default way of compiling. This means if you create any web application either Web Forms or MVC using .NET 4.5 you get this Roslyn csc.exe compilation pre-installed in your project.
    Basically what i needed was to compile and deploy my project without Roslyn or any .exe files on it.
    A simple solution for this issue is that removing Roslyn compiler plugin from your project and using old compiler. In order to remove Roslyn:

    1. “Tools > NuGet Package Manager > Manage NuGet Packages for Solution” in Visual Studio
    2. Find “DotNetCompilerPlatform” and uninstall it
      Hope this will solve your purpose. Basically this will not generate any csc.exe, vbc.exe files inside bin folder.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Yurong Dai

    0 comments No comments

  2. chribonn 21 Reputation points
    2022-06-13T10:50:38.377+00:00

    Hi @YurongDaiMSFT-4508 ,

    Thanks for your reply.

    Is there a way I can achieve the above without installing Visual Studio. The idea is that this machine was not a DEV environment and therefore did not need to have IDEs installed. I would like to avoid this if possible

    Thanks

    0 comments No comments

  3. chribonn 21 Reputation points
    2022-06-13T15:04:43.893+00:00

    I made a short video to demonstrate what I am getting: https://youtu.be/xZTZJVnFAgw

    Is there a way I can disable Roslyn compilation in a simple manner.


  4. chribonn 21 Reputation points
    2022-06-16T09:41:51.97+00:00

    Hi @YurongDaiMSFT-4508

    The enable 32-Bit Applications to True did not work.

    I found the following: disable-roslyn-in-iis-application but I'm not sure this will solve the topic.

    Thanks


  5. Bruce (SqlWork.com) 54,866 Reputation points
    2022-06-16T19:30:19.95+00:00

    the roslyn compilers should be in the bin folder. use visual studio publish to build the deployment folder.

    0 comments No comments