0

I've deployed a .NET Framework web app to an Azure web app, framework version 4.7.2. It works fine on my development machine, but when I try to load the Azure web app I get different errors every time I refresh the page, e.g.:

Could not load file or assembly 'System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.

Could not load file or assembly 'Microsoft.ApplicationInsights.TraceListener' or one of its dependencies. Access is denied.

Why one earth does the error change when the page is refreshed? Normally it stays the same until it's fixed.

nmit026
  • 3,024
  • 2
  • 27
  • 53
  • 1
    The fact that you are having "access is denied" errors, most certainly means that your azure web app does not have the sufficient rights to read the content of a system / application folder. So I guess you're getting the same error message, but for the first DLL the app tries to load every time. If it's asynchronous it might be any of the dll your project needs. The issue is not your error message changing, it's why you have an "Access Denied" error – Miiite Jul 26 '19 at 10:03
  • @Miiite Thanks, the only changes I've made though are updating some nuget packages and the target frameworks for each project to 4.7.2. I can't think how that would have changed any rights or permissions? – nmit026 Jul 26 '19 at 10:07
  • 1
    Really hard to tell without being able to have a look at your whole project configuration. Let's assume you were using .NET 4.6 before, the system.*.dll of that framework version are stored in a different folder than the .NET 4.7.2 system.*.dll. So technically, you did change at least one path in your project, by changing the .NET target. – Miiite Jul 26 '19 at 10:18
  • @Miiite What are the implications of that? Could you explain like I'm five? I upgraded from 4.7 to 4.7.2. Thanks so much for helping me by the way. – nmit026 Jul 26 '19 at 10:22
  • 1
    I am no expert in Azure Web Apps security and access rights unfortunately. All I did was to make assomptions to try to help you discovering what's going on. That being said, to my knowledge any web app has to be run by *some* user (depending on how you configured your web app). My guess is that this user has access to a limited section / directories of your web app's machine or virtual machine, and unfortunately the newest version of .NET (stored in his own directory) would be outside of that allowed scope. – Miiite Jul 26 '19 at 12:24

1 Answers1

0

After uggrading to .NET 4.7.2 from 4.7 and updating lots of nuget packages I was getting different error messages with every refresh (including ones about Antlr3, System.Web.DynamicData, and Application Insights packages). They often said access is denied, BadImageFormatException, Assembly wouldn't load, and one mentioned the temporary internet files folder.

Thanks to this suggestion Antlr3.runtime access denied after updating deployed files I deleted as much stuff on the (Azure web app) server as I thought I could get away with, then redeployed. Then I started getting sensible, consistent error messages. I then realised I had to remove old binding redirects from my web.config file (which included redirects for System.Runtime), which I did, and everything worked again (after a brief error message about temporary internet files which went away upon refresh). Hope that's useful to someone.

nmit026
  • 3,024
  • 2
  • 27
  • 53