Wednesday, April 30, 2014

Assembly Binding Log Viewer - fuslogvw.exe

When assembly binding fails, typically with an exception (usually, FileNotFoundException, FileLoadException, or BadImageFormatException).

At this point the Assembly Binding Log Viewer (fuslogvw.exe) which comes with .NET framework or The Microsoft .NET Framework SDK, I used it with .NET 4.5 the last time and through Developer Command Prompt for VS2013 which ran as Administrator.

When the binding happens, it looks like a Fusion, and "the Assembly Binding Log Viewer" will show you all assembly binds providing the HKLM\Software\Microsoft\Fusion\ForceLog registry value gets set to 1.

To force it to log I did the following setting in registery (by regedit.exe) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion Add: DWORD ForceLog set value to 1 DWORD LogFailures set value to 1 DWORD LogResourceBinds set value to 1

My problem which caught me was about signing assemblies which were strongly named in addition to assembly versioning.

Sample log will be something like the following (but this one is a successful binding sample):
*** Assembly Binder Log Entry (4/28/2014 @ 2:30:11 PM) *** The operation was successful. Bind result: hr = 0x0. The operation completed successfully. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under executable C:\Program Files (x86)\IIS Express\iisexpress.exe --- A detailed error log follows. === Pre-bind state information === LOG: DisplayName = Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///D:/appBranch/DEV-R2/LT/Services/Authentication/Authentication/ LOG: Initial PrivatePath = D:\appBranch\DEV-R2\LT\Services\Authentication\Authentication\bin LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f388dcb0 LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f388dcb0 LOG: AppName = 90e27310 Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: D:\LandTitles\DEV-R2\LT\Services\Authentication\Authentication\web.config LOG: Using host configuration file: C:\Users\Farhad.Bayanati\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: Found assembly by looking in the GAC. LOG: Binding succeeds. Returns assembly from C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll. LOG: Assembly is loaded in default load context.

Share/Bookmark

Monday, April 28, 2014

How to get Assembly full name(VersionNo, Culture, PublickeyToken)

In Visual Studio, Open a project, Debug Menu-->Windows-->Immediate
Shortcut: (Alt + Ctrl + i) or (Ctrl + D, I) open the Immediate Window

?System.Reflection.Assembly.LoadFile(@"C:\Path\YourAssemblyName.dll").FullName


P.S.
If you can't see the immediate window:
I am guessing that you picked a profile that hides this window.
Try: Tools->Import and Export settings->Reset all settings, and pick general development settings.

If you encoutered with following message:
"Design time expression evaluation for class libraries requires the Visual Studio hosting process which is unavailable in this debugging configuration."
Be sure in the project "Enable the Visual Studio hosting process" is checked, enabled.
Be sure in the project "Enable the Visual Studio hosting process" is checked, enabled.

The host process which is pointed to in above message refers to a feature of the CLR, Hosting allows one to configure the CLR before it gets started. One primary use of this is configuring the primary AppDomain and setting up custom security policies. Which is exactly what the hosting process is doing. in debug mode you are running with a customized version of the CLR, one that improves the debugging experience.


Share/Bookmark