c# - 由于 Fody 错误无法编译项目。 Fody(或任何其他代码)没有任何改变

标签 c# fody fody-propertychanged

** 这是 Visual Studio 2013 中的一个问题。

我得到的错误是巨大的而且大部分是无用的,但它的关键是

Error   130 Fody: Could not load 'ModuleWeaver' from 'PropertyChanged.Fody, Version=1.50.3.0, Culture=neutral, PublicKeyToken=null' due to ReflectionTypeLoadException.
It is possible you need to update the package.
exception.LoaderExceptions:
System.IO.FileLoadException: Could not load file or assembly 'Mono.Cecil,     Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its     dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'

同样,由于没有任何变化,我不知道它的一般问题是什么。它正在寻找的 DLL 位于它一直位于的同一个位置。

编辑:显然在这一点上它厌倦了吐出那个错误所以它制造了一个新的

Error   42  The "Fody.WeavingTask" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Cecil, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified.
File name: 'Mono.Cecil, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'
   at ExceptionExtensions.LogException(ILogger logger, Exception exception)
   at Processor.Execute() in c:\TeamCity\buildAgent\work\7495521761d392b9\Fody\Processor.cs:line 56
   at Fody.WeavingTask.Execute() in c:\TeamCity\buildAgent\work\7495521761d392b9\Fody\WeavingTask.cs:line 44
   at     Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

编辑 2:

此外,据称该错误发生在第 50 行的“Fody.targets”中

<Fody.WeavingTask
      AssemblyPath="@(IntermediateAssembly)"
      IntermediateDir="$(IntermediateDir)"
      KeyFilePath="$(FodyKeyFilePath)"
      ProjectDirectory="$(ProjectDir)"
      SolutionDir="$(FodySolutionDir)"
      References="@(ReferencePath)"
      SignAssembly="$(FodySignAssembly)"
      ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
      DefineConstants="$(DefineConstants)"
  />

编辑 3:

我删除了所有与 Fody 关联的文件,Nuget 在构建过程中重新下载了它们。之后的错误与第二个错误相同:

"Error   42  The "Fody.WeavingTask" task failed unexpectedly." 

编辑 4:

真的希望 Fody 的开发人员看到这一点,因为在修复之前我们处于绝对停滞状态。我们无法“恢复”到它工作时的状态,因为当前配置是它工作时的状态。

最佳答案

看起来您的错误实际上是在找到一个名为 ModuleWeaver 的类。此类是 Fody 包的一部分。

只需更新 nuget 包管理器中的包:

   update-package Fody -reinstall

可能会修复它。

否则:确保您的 app.config 文件没有不正确的重定向。 删除此部分,删除所有重定向。 Visual Studio 通常会添加必要的。

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>

再试一次,如果失败,请尝试查找失败的依赖程序集。您可以编写单行命令行应用程序,或使用 LinqPad。

你可以试试LinqPad ,如果您还没有使用它,请粘贴它。

Assembly.LoadFile("path to Fody");
Assembly.LoadFile("path to Mono.Cecil");

您应该得到一个异常,详细说明缺少的库。

关于c# - 由于 Fody 错误无法编译项目。 Fody(或任何其他代码)没有任何改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32893891/

相关文章:

c# - UWP 应用程序从商店下载时崩溃,但在旁加载时不会崩溃

c# - 我应该把 KeepAlive 放在我的 finally block 中吗?

.net - 使用 PropertyChanged.Fody 构建应用程序时出错

c# - Fody 仅在 MSBuild 16 及更高版本上受支持。当前版本 : 15

c# - 这个波浪号在 C# 中的用途是什么

c# - 针对 MS Access 的 LINQ asp.net 页面。

mvvmcross - 在 MvvmCross 中集成 Fody NotifyPropertyChanged

mvvm - PropertyChanged.Fody迁移通知属性已更改

wpf - 将元素可见性绑定(bind)到 ViewModel 属性,并提供设计时支持