-1

I have created a new Asp.net Web Api Solution.I hosted it on local server using IIS. When i am trying to browse the solution from my web browser it is showing the following error.

Could not load file or assembly'Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.

Any one has any solution to fix this issue ?

The controller that I have created is :

[RoutePrefix("shipmentsync")]
    public class ShipmentSync : ApiController
    {
        ShipmentSyncBusinessRepository shipmentSync;

        [Route("creation")]
        public void SyncSalesOrderCreation()
        {
            shipmentSync = new ShipmentSyncBusinessRepository();
        }
    }

I want to see this method as end point on web browser.

Sandeep Pandey
  • 184
  • 1
  • 17

1 Answers1

1

I think it may be your application pool don't have a permission to access your dll file please try this

If you application pool is named "DefaultAppPool" (just replace this text below if it is named differently)

Open Windows Explorer

1.Select a file or directory.

2.Right click the file and select "Properties"

3.Select the "Security" tab

4.Click the "Edit" and then "Add" button

5.Click the "Locations" button and make sure you select the local machine. (Not the Windows domain if the server belongs to one.)

6.Enter "IIS AppPool\DefaultAppPool" in the "Enter the object names to select:" text box. (Don't forget to change "DefaultAppPool" here to whatever you named your application pool.)

  1. Click the "Check Names" button and click "OK".

    OR

To resolve this issue, you will need to remove the Roslyn compiler from the project template. Removing Roslyn shouldn't affect your code's functionality.

Do the following steps:

Remove from following Nuget Packages using command line shown below (or you can use GUI of Nuget Package manager by Right Clicking on Root Project Solution and removing them).

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

Remove the following code from your Web.Config file and restart IIS. (Use this method only if step 1 doesn't solve your problem.)

 <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>
Abinash
  • 471
  • 3
  • 13
  • Tried Rebuild , cleaned and build , Checked app pool, permissions, restarted IIS, even reopened VS still it is same. i ma not getting what is this DotNetCompilerPlatform. – Sandeep Pandey Jan 08 '18 at 10:32