After making significant changes to a C# Web Application I got the following message displayed on starting the web site from Visual Studio using IIS Express:
Parser Error Message: Could not load file or assembly 'MyDomain.UI.UserSite' or one of its dependencies. The system cannot find the file specified. ... Assembly Load Trace: The following information can be helpful to determine why the assembly 'MyDomain.UI.UserSite' could not be loaded. ... === Pre-bind state information === LOG: User = MyComputerMyUser LOG: DisplayName = MyDomain.UI.UserSite (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: MyDomain.UI.UserSite | Domain ID: 2 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. LOG: Appbase = file:///C:/_Source/MyDomain/MyProject-trunk/UI/UI.UserSite/ LOG: Initial PrivatePath = C:_SourceMyDomainMyProject-trunkUIUI.UserSitebin Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: C:_SourceMyDomainMyProject-trunkUIUI.UserSite2web.config LOG: Using host configuration file: C:UsersMyUserDocumentsIISExpressconfigaspnet.config LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: The same bind was seen before, and was failed with hr = 0x80070002.
There are two approaches to this sort of issue, either to fool around with your project dependencies and config files until you find the problem or try to get more information. Taking the latter approach and searching for help soon turns up Microsoft’s Assembly Binding Log Viewer (a.k.a. Fusion Log Viewer).
The viewer (fuslogvw.exe) can be easily started from the “Developer Command Prompt for VS2012”. However, to get it actually to do anything required a couple of extra steps:
- Make sure you run the Viewer as an Administrator. If you do not you will not be able to change any of the Settings.
- Open the Settings and change:
- Log Bind Failures to Disk to on
- Enable Custom Log Path to checked
- Custom Log Path to a folder on your computer that you have already set up for this purpose.
- Ensure that all users on the computer have Write and Modify access to the Custom Log Path folder.
Now run the Web Application again and then click Refresh in the Log Viewer. An entry for the failing bind should be displayed; select it and click View Log to see the details.
Lastly, remember to turn the logging off in the Log Viewer after you are done as the documentation contains various warnings about what effects it may have.
See also old but useful posts on the registry entries for the Log Viewer and another on “Debugging Assembly Loading Failures“.
Using: Visual Studio 2012; .Net 4.0; Assembly Binding Log Viewer 4.0.30319.17929;