2006-08-27

bindingRedirect

I ran into a wall today where i was getting an exception akin to this:

Could not load file or assembly 'dommons, Version=0.0.33.0, Culture=neutral, PublicKeyToken=873d6a369a01a6bd' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Now im fine with the error, its a shared strong named assembly, that NOT in the GAC. So how do i fix it. It didn't take long to find the solution was to add a bindingRedirect. I was going to map the 0.0.33.0 version to the lastest 0.0.36.0 one. Easier said than done i'm afraid.
Here is a link explaining the redirect:
http://www.diranieh.com/NETAssemblies/Assemblies.htm

All i would have to do would be to put this in my web.config:


  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="dommons" 
  publicKeyToken="873d6a369a01a6bd" culture="neutral" />
        <bindingRedirect oldVersion="0.0.33.0" newVersion="0.0.36.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


Though this did not fix the problem. A lot of material seems to be geared towards the assemblies being in the GAC or running as a client application. Not my case of build versions mismateching. To a newer version as well.

So i then spent the next half a day figuring out what was going on.
First checking i was doing it correctly:
http://blogs.msdn.com/suzcook/archive/2004/05/14/132022.aspx
http://plans.thefrankes.com/tutorials/Assemblies/
http://blogs.msdn.com/junfeng/archive/2004/11/16/258081.aspx

I was sure i had the syntax right, time to start using the assembly loading debugger, a tool called fuslogvw. In the start menu, open up the .net framework command prompt and type that. Also make sure you restart IIS to register it, otherwise nothing happens. Here are some more links for debugging:
http://www.grimes.demon.co.uk/workshops/fusWSFive.htm
http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx
http://www.grimes.demon.co.uk/workshops/fusWSFive.htm

So what was my problem, it seems that the redirect was not working. This happens first in the process (msdn). But why was it failing.
The error from fusion log viewer was this:

  *** Assembly Binder Log Entry  (27/08/2006 @ 3:29:10 PM) ***
  The operation failed.
  Bind result: hr = 0x80131040. No description available.
  Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
  Running under executable  c:\windows\system32\inetsrv\w3wp.exe
  --- A detailed error log follows.
  === Pre-bind state information ===
  LOG: User = NT AUTHORITY\NETWORK SERVICE
  LOG: DisplayName = dommons, Version=0.0.33.0, Culture=neutral, PublicKeyToken=873d6a369a01a6bd
  (Fully-specified)
  LOG: Appbase = file:///D:/projects/svn/project/trunk/project-web/
  LOG: Initial PrivatePath = D:\projects\svn\project\trunk\project-web\bin
  LOG: Dynamic Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\91bd8e69
  LOG: Cache Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\91bd8e69
  LOG: AppName = fec991e1
  Calling assembly : repository, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
  ===
  LOG: This bind starts in default load context.
  LOG: Using application configuration file: D:\projects\svn\project\trunk\project-web\web.config
  LOG: Using host configuration file: file:////?\c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config
  LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
  LOG: Post-policy reference: dommons, Version=0.0.33.0, Culture=neutral, PublicKeyToken=873d6a369a01a6bd
  LOG: GAC Lookup was unsuccessful.
  LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files
 /project/91bd8e69/fec991e1/dommons.DLL.
  LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files
 /project/91bd8e69/fec991e1/dommons/dommons.DLL.
  LOG: Attempting download of new URL file:///D:/projects/svn/project/trunk/project-web/bin/dommons.DLL.
  LOG: Assembly download was successful. Attempting setup of file: D:\projects\svn\project\trunk\project-web\
 bin\dommons.dll
  LOG: Entering download cache setup phase.
  LOG: Assembly Name is: dommons, Version=0.0.36.0, Culture=neutral, PublicKeyToken=873d6a369a01a6bd
  WRN: Comparing the assembly name resulted in the mismatch: Build Number
  ERR: The assembly reference did not match the assembly definition found.
  ERR: Setup failed with hr = 0x80131040.
  ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Note the two red lines. The redirect was not working, and as the 33 version could not be found, the application start failed. In frustration i tried a suggestion to put the redirect in the machine.config file, and what do you know, the whole thing started to work. Now at least i know why it isn't working it might be a little easier to figure out the cause. I think i read a permission on a security namespace item may need to be set.

8 comments:

Anonymous said...

Hello all


Get a better improved ebay FREE at http://www.BuySellDirect.net.


Do your self a favorite buy using http://www.BuySellDirect.net FREE service to make a second income.

Anonymous said...

It's not my first time to pay a visit this web site, i am browsing this web site dailly and take fastidious data from here every
day.

Feel free to surf to my website ... world of warplanes cheats

Anonymous said...

It's hzгԀ to find knowledgeable people in tɦis partіcular subject, but you seem liike you know what you're
talkinǥ about! Thanks

Here is my blog post ... coffee urn rental san diego

Anonymous said...

gaboon   gadded   gadder   gaddis   gadfly   gadget   gadids
  gadoid. quavered quaverer quayages quaylike quayside queasier queasily queazier.
datives  daturas  daturic  daubers  daubery  daubier  daubing  daunder.


My page ... http://www.fruktose-sorbit.de/wiki/index.php?title=Benutzer:CathariHollar

Anonymous said...

It іs not easy to simply give up and move on whеn you love this
woman. Rather than shooting youгsеlf in the
foot, the correct tactic is to ƅring your age
out into the open -- and remove it as a concern. And, the
truth is that you don't hаve to become somebody else in order to come
across aѕ an alpha mаn in fгont of man.

My web site ultimate herpes protocol pdf

Anonymous said...

Hello my family member! I wish to say that this article is awesome, nice written and come
with approximately all important infos. I would like to look more posts like this .


Also visit my weblog: spartan wars hacks

toashes said...

pop over to this website dolabuy replica his response have a peek at this web-site see here gucci replica handbags

theighn said...

j9x51y7l05 t3t13b8g77 i7v94e7a11 p0y38m4b26 n6c06j3k87 r6t77p4y03