eventregister.exe 无法加载 Azure 服务运行时



我们正在使用 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...devpackagesMicrosoft.Diagnostics.Tracing.EventRegister.1.0.16toolsMicrosoft.Diagnostics.Tracing.EventRegister.targets(132,5): error MSB3073: The command ""C:Source...devpackagesMicrosoft.Diagnostics.Tracing.EventRegister.1.0.16toolseventRegister.exe" -DumpRegDlls @"C:Source...DebugmyDLL.eventRegister.rsp" "C:Source...DebugmyDLL.dll" " exited with code 1.

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

可能有一个引用再次引用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,这是最糟糕的解决方案)

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

您的配置文件应该缺少绑定重定向。您始终可以将其置于源代码管理之下,以便您的构建可以在不同的计算机上运行。

最新更新