Resolving .NET TypeLoadExceptions in Azure App Service

2

I have an Azure App Service where I published my .NET application (.NET Framework 4.7.2). The application works fine on local Visual Studio IIS Express.

When I run it in the App Service I get TypeLoadExceptions. The interesting parts are, for example, these errors:

    - System.IO.FileLoadException: Could not load file or assembly 'EPiServer.Forms, Version=3.0.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'EPiServer.Forms, Version=3.0.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Now, in any virtual server case I could just enable the EnableLog registry value and see more about what dependency I am missing. I tried to change the registry value thru PowerShell but got access denied. I haven't found any Fusion Log viewer in Azure either.

What is the correct way to debug Assembly binding errors in Azure App Service?

Browsing through this: How to enable assembly bind failure logging (Fusion) in .NET but it does not say anything about doing it in Azure App Service.

asp.net
.net
azure
assemblies
azure-web-app-service
asked on Stack Overflow Jan 11, 2019 by Juho Rutila

2 Answers

3

There is no way to get Fusion logging in Azure App service now. Because it's required to modify registry to enable it. But modifying registry is not allowed in Azure App Service. Refer to here for more info.

The error "The located assembly's manifest definition does not match the assembly reference." usually means the assembly the runtime finds does not match that you specified in application.

In Azure web app, you can check the dll via FTP. Check "Accessing files via ftp". The dlls usually locates in \wwwroot\bin. Confirm the dll info matches the dll you use in the solution. You may check web.config and package.config whether you specified different version for this assembly.

Also refer to here to understand how .net runtime locates dll.

answered on Stack Overflow Jan 15, 2019 by axfd • edited Jan 30, 2019 by axfd
3

Just wanted to post an update to say that Fusion logging on an Azure App service can now be enabled, there's an article on it here.

Basically all you have to do is add an application setting called WEBSITE_FUSIONLOGGING_ENABLED and set it to 1.

answered on Stack Overflow Mar 19, 2021 by angholt

User contributions licensed under CC BY-SA 3.0