Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

binding redirect not working in test project

When applying a binding redirect in the app.config of the test project. The runtime refuses to obey the redirect command and keeps searching for the old version of the assembly

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Msdcc.Common" publicKeyToken="9d9c15280f7f1425"/>
      <bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

well i had heard about the default namespace creating problems(from a very wise man) so i added the "xmlns="urn:schemas-microsoft-com:asm.v1". Tried running the test case still no go. Opened up Fusion Log Viewer checked the problem and wonders of wonder it is till looking for the old dll. The really helpfull message given below was deciphered using this post http://msdn.microsoft.com/en-us/magazine/dd727509.aspx

*** Assembly Binder Log Entry  (28/07/2010 @ 18:59:36) ***

The operation failed.
Bind result: hr = 0x80131040. No description available.

Assembly manager loaded from:  C:\WINNT\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = BELGACOM\id820374
LOG: DisplayName = Msdcc.Common, Version=2.2.0.0, Culture=neutral, PublicKeyToken=9d9c15280f7f1425
 (Fully-specified)
LOG: Appbase = file:///c:/data/source/explorev1/explore.root/explore/euc.explore.domainobjectstest/bin/debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: Using application configuration file: c:\data\source\explorev1\explore.root\explore\euc.explore.domainobjectstest\bin\debug\euc.explore.domainobjectstest.dll.config
LOG: Using machine configuration file from C:\WINNT\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///c:/data/source/explorev1/explore.root/explore/euc.explore.domainobjectstest/bin/debug/Msdcc.Common.DLL.
LOG: Assembly download was successful. Attempting setup of file: c:\data\source\explorev1\explore.root\explore\euc.explore.domainobjectstest\bin\debug\Msdcc.Common.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Msdcc.Common, Version=2.4.0.0, Culture=neutral, PublicKeyToken=9d9c15280f7f1425
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

My Though Process

This got me thinking why does it still not do the assembly redirection if the link is present in my config file.

So newbie that i am i just decided i will do exactly what the old man told me to do and removed the namespace declaration from the configuration element and hey presto it worked. xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"

My Question after this very long story is from what i understand the namespace declarations is only supposed to mess with the Intellisense why is it screwing around with the assembly binding ???

like image 790
David Xavier Avatar asked Jul 28 '10 17:07

David Xavier


People also ask

How do binding redirects work?

Rely on automatic binding redirection This means that if two components reference different versions of the same strong-named assembly, the runtime automatically adds a binding redirection to the newer version of the assembly in the output app configuration (app. config) file.

How do I enable and disable automatic binding redirection?

Right-click the project in Solution Explorer and select Properties. On the Application page, uncheck the Auto-generate binding redirects option. If you don't see the option, you'll need to manually disable the feature in the project file.


1 Answers

Loading an assembly into the Reflection load context by design ignores publisher policy and binding redirect policy. Junfeng Zhang examines why this is in his excellent blog.

A similar question is asked here: Is it possible to use Assembly.ReflectionOnlyLoad together with publisher policies / assembly versioning?

like image 58
codekaizen Avatar answered Sep 28 '22 21:09

codekaizen