5

我们正在使用 EventSource nuget 包,但我们遇到了构建错误:

1>EXEC : error : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

1> LoaderException:

1> System.IO.FileLoadException: Cannot resolve dependency to assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.    
1>C:\Source\...\dev\packages\Microsoft.Diagnostics.Tracing.EventRegister.1.0.16\tools\Microsoft.Diagnostics.Tracing.EventRegister.targets(132,5): error MSB3073: The command ""C:\Source\...\dev\packages\Microsoft.Diagnostics.Tracing.EventRegister.1.0.16\tools\eventRegister.exe" -DumpRegDlls @"C:\Source\...\Debug\myDLL.eventRegister.rsp" "C:\Source\...\Debug\myDLL.dll" " exited with code 1.

我们可以通过在 Machine.Config(1.0.0.0 到 2.2.0.0)中转发程序集来解决这个问题,但这感觉像是一个糟糕的“修复”。我根本不明白为什么 EventRegister 应用程序应该加载 Azure 服务运行时,这对我来说没有意义。

4

2 回答 2

2

可能有一个引用再次引用 Microsoft.WindowsAzure.ServiceRuntime 1.0.0.0。

想到3个解决方案:

  1. 找到有问题的引用,它引用 Microsoft.WindowsAzure.ServiceRuntime 版本 1.0.0.0 并更新/删除/修复它(.NET Reflector 可以帮助你)
  2. 安装 Azure SDK 1 或具有 Microsoft.WindowsAzure.ServiceRuntime 版本 1 的东西(这可能是一个糟糕的解决方案)
  3. 为 Microsoft.WindowsAzure.ServiceRuntime 进行机器范围的程序集转发(IMO,这是最糟糕的解决方案)
于 2014-02-12T10:40:36.170 回答
2

另一种选择是将 eventRegister.exe.config 放入 packages\Microsoft.Diagnostics.Tracing.EventRegister.1.0.26\build (1.0.26 恰好是我现在使用的版本)。

您的配置文件应该缺少 bindingRedirect。您始终可以将其置于源代码控制之下,因此您的构建可以在不同的机器上运行。

于 2017-09-16T18:37:10.290 回答