Microsoft.StreamProcessing 导致程序加载异常
Microsoft.StreamProcessing causes exception on program loading
我有一个有点复杂的交易应用程序,可以处理大量事件消息。这是一个 Windows
MEF
应用程序,在 runtime
.
自动加载 assemblies
我决定尝试 Microsoft.StreamProcessing
将事件转换为 IStreamable
。我迈着缓慢的步伐。首先,我刚刚通过 nuget
将程序集添加到我的 project
。然后添加
using Microsoft.StreamProcessing;
代码,但没有声明任何类型。运行良好。
接下来,我在代码中添加了单行:
IStreamable<Empty, IQuote> markeDatatStream
;
我就是这么做的。我没有以任何方式使用它,只是添加了一行。这一次,在加载程序时,出现以下异常。当我查看推荐的 LoaderExceptions
字段时,我得到:
{"Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.":"System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"}
如果我删除代码中的单行
IStreamable<Empty, IQuote> markeDatatStream
;
它工作正常。
完整异常:
System.Reflection.ReflectionTypeLoadException
HResult=0x80131602
Message=Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Source=mscorlib
StackTrace:
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)
at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part)
at System.ComponentModel.Composition.Hosting.CompositionServices.TryInvoke(Action action)
at System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.Compose(CompositionBatch batch)
at Trader.MainForm.InitializeTradingEngine() in C:\Users\idf\Projects\Trader-Orig-Working\Trader\Trader\MainForm.cs:line 200
at Trader.MainForm..ctor(String logFilePath) in C:\Users\idf\Projects\Trader-Orig-Working\Trader\Trader\MainForm.cs:line 113
at Trader.Program.Main() in C:\Users\idf\Projects\Trader-Orig-Working\Trader\Trader\Program.cs:line 231
这里的问题大概是strong naming.
总结:
如果您包含强命名的库 A,并使用带 assembly-version 1.0.0.0 的库 B
并且您正在使用库 B,但是使用 assembly-version 1.1.0.0,那么您将遇到加载错误 - 令人困惑的错误 "The system cannot find the file specified"
然后你需要一个绑定:
<dependentAssembly>
<assemblyIdentity name="B" publicKeyToken="32ab4ba45e0a69a1" culture="en-us" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
所以有人在您的应用程序中构建 System.Runtime.Loader,版本 = 4.0.0.0,但您可能(可能通过另一个库)提供另一个版本的 System.Runtime.Loader。
另一个选项是将 System.Runtime.Loader 版本添加到 GAC
我有一个有点复杂的交易应用程序,可以处理大量事件消息。这是一个 Windows
MEF
应用程序,在 runtime
.
assemblies
我决定尝试 Microsoft.StreamProcessing
将事件转换为 IStreamable
。我迈着缓慢的步伐。首先,我刚刚通过 nuget
将程序集添加到我的 project
。然后添加
using Microsoft.StreamProcessing;
代码,但没有声明任何类型。运行良好。
接下来,我在代码中添加了单行:
IStreamable<Empty, IQuote> markeDatatStream
;
我就是这么做的。我没有以任何方式使用它,只是添加了一行。这一次,在加载程序时,出现以下异常。当我查看推荐的 LoaderExceptions
字段时,我得到:
{"Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.":"System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"}
如果我删除代码中的单行
IStreamable<Empty, IQuote> markeDatatStream
;
它工作正常。
完整异常:
System.Reflection.ReflectionTypeLoadException
HResult=0x80131602
Message=Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Source=mscorlib
StackTrace:
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)
at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part)
at System.ComponentModel.Composition.Hosting.CompositionServices.TryInvoke(Action action)
at System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.Compose(CompositionBatch batch)
at Trader.MainForm.InitializeTradingEngine() in C:\Users\idf\Projects\Trader-Orig-Working\Trader\Trader\MainForm.cs:line 200
at Trader.MainForm..ctor(String logFilePath) in C:\Users\idf\Projects\Trader-Orig-Working\Trader\Trader\MainForm.cs:line 113
at Trader.Program.Main() in C:\Users\idf\Projects\Trader-Orig-Working\Trader\Trader\Program.cs:line 231
这里的问题大概是strong naming.
总结:
如果您包含强命名的库 A,并使用带 assembly-version 1.0.0.0 的库 B 并且您正在使用库 B,但是使用 assembly-version 1.1.0.0,那么您将遇到加载错误 - 令人困惑的错误 "The system cannot find the file specified"
然后你需要一个绑定:
<dependentAssembly>
<assemblyIdentity name="B" publicKeyToken="32ab4ba45e0a69a1" culture="en-us" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
所以有人在您的应用程序中构建 System.Runtime.Loader,版本 = 4.0.0.0,但您可能(可能通过另一个库)提供另一个版本的 System.Runtime.Loader。
另一个选项是将 System.Runtime.Loader 版本添加到 GAC