eventregister.exe无法加载Azure ServiceRuntime

noo*_*yte 5 .net azure etw-eventsource

我们正在使用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.
Run Code Online (Sandbox Code Playgroud)

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

and*_*rso 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,这是最糟糕的解决方案)