Monday, February 17, 2014

Assembly Binding, no need to use Fuslogvw.exe

I had a problem deploying a windows service to a customer server. of course, at my servers, everything works great but not there.
The problem was a DLL that did not load and the service would not start.

I searched around how to log the binding of the Dlls and found the references to the  Fuslogvw.exe. I did not find the file where it was supposed to be because on a server you do not install by default the full SDK of .Net.   I thought that may be the application is not needed and looked some more and found this excellent "Back to the Basics article" by Scott Hanselman :
http://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx

you need to set two registry settings:
First set the output directory on this string value : HKLM\Software\Microsoft\Fusion\LogPath
second, turn fusion on  by setting DWORD value to 1 : HKLM\Software\Microsoft\Fusion\ForceLog
Be careful with this.
After settings the ForceLog to 1, perform the operation, I had to start the service, then check the intended path for the file. They are generated immediately.
Then you can set the ForceLog calue back to 0.

You get two directories: "Default" and "NativeImage". the log files are created in both directories. I opened both directories and some problem in the native directory did not log in the Native directory, So I focused on the Default Directory.
Under the above directories I got a directory for the Application I tried to check and it had an Xml file for each Dll and they opened by the browser and are easy to read.
After reading the files I located the problematic Dlls and managed to load them.

Anyway, Even after the services did start., I got  no errors from the service and it did not write to the windows event log or the application log. So I checked again and the service would start but it did not load all the Objects it was suppose to load so it did nothing. Great.
I Checked the fusion files again until I found all the problematic references and fixed them.

The problem : For a reason I still need to check, after recompiling the projects manually, I got different Dll files with different sizes. After manually deleting the output bin directory and compiling the service again, I deployed the system again and It worked.

No comments:

Post a Comment