When deploying a web project to Azure, The cocould not load file or assembly problem sometimes occurs. This problem is generally caused by incorrect versions of some dependent assemblies. For example, MVC 3 and mvc4 may be installed simultaneously on the development machine. The development machine will not be faulty, because the corresponding assembly can be found. However, after being deployed to Azure, the dependency file problem occurs. For example, the problem is as follows:
"Cocould not load file or assembly 'System. web. webpages, version = 2.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35 'or one of its dependencies. the located assembly's manifest definition does not match the Assembly reference. (exception from hresult: 0x80131040 )"
Cocould not load file or assembly'System. Web. helpers, version = 1.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35'Or one of its Dependencies. The system cannot find the file specified.
If you log on to the azure machine and modify the Registry HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Fusion! Enablelog] (DWORD) to 1
You can see more detailed information, for example:
=== Pre-bind state information === log: User = nt authority \ Network servicelog: displayname = system. web. helpers, version = 1.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35 (fully-specified) log: appbase = file: // E:/sitesroot/1/log: initial privatepath = E: \ sitesroot \ 1 \ bincalling Assembly: (unknown ). === log: This bind starts in default load context. log: Using application configuration file: e: \ sitesroot \ 1 \ Web. configlog: using host configuration file: D: \ windows \ Microsoft. net \ framework64 \ v4.0.30319 \ ASPnet. configlog: using machine configuration file from D: \ windows \ Microsoft. net \ framework64 \ v4.0.30319 \ config \ machine. config. log: Post-Policy Reference: system. web. helpers, version = 1.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35log: Attempting download of new URL File: // D:/Windows/Microsoft. net/framework64/v4.0.30319/Temporary ASP. net files/STs/5c2051b2/ac0bf06b/system. web. helpers. DLL. log: Attempting download of new URL File: // D:/Windows/Microsoft. net/framework64/v4.0.30319/Temporary ASP. net files/STs/5c2051b2/ac0bf06b/system. web. helpers/system. web. helpers. DLL. log: Attempting download of new URL File: // E:/sitesroot/1/bin/system. web. helpers. DLL. log: Attempting download of new URL File: // E:/sitesroot/1/bin/system. web. helpers/system. web. helpers. DLL. log: Attempting download of new URL File: // D:/Windows/Microsoft. net/framework64/v4.0.30319/Temporary ASP. net files/STs/5c2051b2/ac0bf06b/system. web. helpers. EXE. log: Attempting download of new URL File: // D:/Windows/Microsoft. net/framework64/v4.0.30319/Temporary ASP. net files/STs/5c2051b2/ac0bf06b/system. web. helpers/system. web. helpers. EXE. log: Attempting download of new URL File: // E:/sitesroot/1/bin/system. web. helpers. EXE. log: Attempting download of new URL File: // E:/sitesroot/1/bin/system. web. helpers/system. web. helpers. EXE.
Solution: Search for each assembly under the references of a project and find its version.
If the version is incorrect, You Need To rereference the correct version.
If no supported libraries or runtime is installed on Azure, modify copy local to true so that the DLL is packaged into the azure package.
sometimes these problems are difficult to identify. The best and most time-consuming method is to pull the entire package down and check the dependencies using tools such as ilspy.