A couple of weeks ago a received an error report from a customer of my MZ-Tools add-in saying that VS 2005 failed to load it with error “Unknown error” and error code 0x80131018. Searching my e-mail history it happened that that error was already reported by a previous customer months ago, but it was not clear how it was solved. The current customer tried to reinstall the add-in, to reinstall VS 2005 and even to format the hard drive, to no avail. Searching on the web, there is little information about this error, only that it is mapped to COR_E_ASSEMBLYEXPECTED and that it caused because a .NET assembly doesn’t have a manifest, that is, it is not a .NET assembly actually. In fact, this method is used to know if a DLL is a .NET assembly or not. But how could it be that a .NET add-in assembly does have a missing manifest? The customer sent it to me and the manifest was there. In fact, it loaded perfectly on my machine, and on another machine of him. The fuslogvw.exe tool gave this log:
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe.Config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\configmachine.config.
LOG: Attempting download of new URL file:///C:/Program Files/MZTools2005/MZTools5.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Program Files\MZTools2005\MZTools5.dll
LOG: Entering run-from-source setup phase.
ERR: Error extracting manifest import from file (hr = 0x80131018).
ERR: Failed to complete setup of assembly (hr = 0x80131018). Probing terminated.
In the tests that I asked him to perform, the assembly loaded correctly using Assembly.LoadFrom from a Windows application or using the Reflector for .NET tool, so the error happened only inside VS 2005.
Finally, and when I was quite desperate with this problem, the customer discovered that the problem was caused by the version 2007 of his antivirus, which I won’t cite, but suffice to say that the culprit was its “Protection Against Unknown Threats” feature. As soon as he deactivated that feature, the add-in loaded quite happily.
I hope this helps if you ever find this problem.