【发布时间】:2015-11-14 09:29:00
【问题描述】:
我正在开发一个基于 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.
我在失败中注意到两件有趣的事情:
- 失败的加载有“调用程序集:(未知)”
- 虽然引用了正确的应用配置文件,但没有发现重定向的消息
这是一个堆栈跟踪,显示了如何调用 load:
数据:System.Collections.ListDictionaryInternal
目标站点:
H结果:-2146234304
堆栈跟踪:
在 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, 证据 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 程序集,字符串 assemblyFullName)
【问题讨论】:
-
欢迎来到 StackOverflow,请阅读"How do I ask a good question?"
标签: .net wpf redirect binding prism