首页 文章

装配绑定重定向失败,WPF / PRISM

提问于
浏览
0

我正在开发一个基于Prism框架的WPF应用程序 . 我正在尝试使用绑定重定向,以便我可以替换我在本地构建的程序集,以构建在构建系统上的程序集 .

从融合日志中可以看出,有时会使用重定向,有时则不会 . 这一切都来自同一次运行应用程序的同一个日志:

融合日志中的成功加载:

*** 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.

现在无法加载:

*** 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.

我在失败中注意到的两件有趣的事情:

  • 失败的加载有"Calling assembly : (Unknown)"

  • 虽然引用了正确的应用程序配置文件,但没有关于找到重定向的消息

下面是一个堆栈跟踪,显示了如何调用load: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)

在System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)

在System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)

在System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection)

在System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&stackMark,Boolean forIntrospection)

在System.Reflection.Assembly.ReflectionOnlyLoad(String assemblyString)

在Microsoft.Practices.Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.OnReflectionOnlyResolve(ResolveEventArgs args,DirectoryInfo目录)

在Microsoft.Practices.Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader . <> c__DisplayClass7.b__4(Object sender,ResolveEventArgs args)

在System.AppDomain.OnReflectionOnlyAssemblyResolveEvent(RuntimeAssembly assembly,String assemblyFullName)

1 回答

  • 0

    事实证明,第二次失败的原因是PRISM调用System.Reflection.Assembly.ReflectionOnlyLoad,根据Microsoft忽略绑定重定向 .

    我最初的问题是我想调试一个程序集,该程序集是所有程序集都已签名的应用程序的一部分 . 我想使用延迟签名构建一个程序集并使用绑定重定向,以便满足所有其他程序集引用 .

    我发现如果我只是将我想要构建/调试的程序集的程序集版本更改为与为应用程序构建的版本相同,那么我不需要绑定重定向 .

相关问题