title: ASP.NET Core 1.1 runs fine locally but when publishing to Azure says "An error occurred while starting the application."
body: <p>I've been developing an ASP.NET Core web app, based largely on the MVC template provided in Visual Studio 2017 RC2. It runs just fine in local debug mode, but when I try to publish it to an Azure hosted web app, I get this error:</p>
  
  <p><a href="https://i.stack.imgur.com/FfnGh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FfnGh.png" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>An error occurred while starting the application.</p>
    
    <p>.NET Core X86 v4.1.1.0    |   Microsoft.AspNetCore.Hosting version
    1.1.0-rtm-22752    |    Microsoft Windows 6.2.9200</p>
  </blockquote>
  
  <p>I've tried setting <code>stdoutLogEnabled="true"</code> in the web.config file, but it seems to have no effect, the error is the same.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>With some help I managed to retrieve the log, and it says:</p>
  
  <pre><code>Application startup exception: System.TypeLoadException: Could not load type 'System.IO.File' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.    
     at Microsoft.Extensions.DependencyModel.FileWrapper.OpenRead(String path)
     at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadEntryAssemblyContext(IDependencyContextReader reader)
     at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)    
     at Microsoft.Extensions.DependencyModel.DependencyContext.Load(Assembly assembly)    
     at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.DiscoverAssemblyParts(String entryPointAssemblyName)    
     at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)    
     at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)    
     at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)    
     at Bla.Api.Startup.ConfigureServices(IServiceCollection services) in C:\Users\user\Source\Workspaces\Bla\Bla.Api\src\Bla.Api\Startup.cs:line 73
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
     at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
     at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
  
  Hosting environment: Production    
  Content root path: D:\home\site\wwwroot    
  Now listening on: http://localhost:1264    
  Application started. Press Ctrl+C to shut down.
  </code></pre>
  
  <p>The line of code it refers to at line 73 is:</p>
  
  <pre><code>services.AddMvc();
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>My global.json file looks like this (where Bla.Api is the name of the project, and the file sits in the solution root folder).</p>
  
  <pre><code>{
    "projects": [ "Bla.Api" ],
    "sdk": {
      "version": "1.1.0"
    }
  }
  </code></pre>