I am working on a WPF app that is built upon the Prism framework. I am trying to use a binding redirect so that I can substitute an assembly that I have built locally for one that was built on the build system.
It appears from the fusion log that sometimes the redirect is used and sometimes it is not. This is all from the same log from the same attempt to run the application:
Successful load in fusion log:
*** Assembly Binder Log Entry (8/20/2015 @ 11:54:39 AM) ***
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:\ABB ServicePort\ServicePort Explorer\ABB.ServicePortExplorer.Startup.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = ABB.Service.ServicePort.Data, Version=15.2.0.51, Culture=neutral, PublicKeyToken=8ccfd5d539e711ba
(Fully-specified)
LOG: Appbase = file:///C:/xxx/xxx/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = xxx.Startup.exe
Calling assembly : xxx.Startup, Version=15.2.0.3, Culture=neutral, PublicKeyToken=8ccfd5d539e711ba.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\xxx\xxx\xxx.Startup.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 15.2.0.51 redirected to 15.2.999.999.
LOG: Post-policy reference: xxx.Data, Version=15.2.999.999, Culture=neutral, PublicKeyToken=8ccfd5d539e711ba
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/xxx/xxx/xxx.Data.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\xxx\xxx\xxx.Data.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: xxx.Data, Version=15.2.999.999, Culture=neutral, PublicKeyToken=8ccfd5d539e711ba
LOG: Binding succeeds. Returns assembly from C:\xxx\xxx\xxx.Data.dll.
LOG: Assembly is loaded in default load context.
Now the failure to load:
*** Assembly Binder Log Entry (8/20/2015 @ 11:54:45 AM) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\xxx\xxx\xxx.Startup.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = xxx.Data, Version=15.2.0.51, Culture=neutral, PublicKeyToken=8ccfd5d539e711ba
(Fully-specified)
LOG: Appbase = file:///C:/xxx/xxx/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = xxx.Startup.exe
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: Using application configuration file: C:\xxx\xxx\xxx.Startup.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/xxx/xxx/xxx.Data.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\xxx\xxx\xxx.Data.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: xxx.Data, Version=15.2.999.999, Culture=neutral, PublicKeyToken=8ccfd5d539e711ba
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Two interesting things that I noticed in the failure:
- The failed load has "Calling assembly : (Unknown)"
- Although the correct app config file is referenced, there is no message about a redirect being found
Here is a stack trace that shows how load is being called:
Data : System.Collections.ListDictionaryInternal
TargetSite :
HResult : -2146234304
Stack Trace :
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.ReflectionOnlyLoad(String assemblyString)
at Microsoft.Practices.Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.OnReflectionOnlyResolve(ResolveEventArgs args, DirectoryInfo directory)
at Microsoft.Practices.Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.<>c__DisplayClass7.b__4(Object sender, ResolveEventArgs args)
at System.AppDomain.OnReflectionOnlyAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)