Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to compile project due to Fody errors. Nothing with Fody (or any other code) has been changed

** This is an issue in Visual Studio 2013.

The error I'm getting is massive and mostly useless, but the crux of it is

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'

Again since there have been no changes, I have no idea what it's problem is in general. The DLL it is looking for is sitting in the same place it has always been sitting.

Edit: apparently at this point it got tired of spitting out that error so it fabricated a new one

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()

Edit 2:

Also, the error is allegedly taking place inside "Fody.targets" on line 50 which is

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

Edit 3:

I deleted all the files associated with Fody and Nuget redownloaded them during the build process. The error after that is the same as the 2nd error:

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

Edit 4:

I really hope the dev of Fody sees this because we're at an absolute standstill until this is fixed. We can't "revert" back to when it was working because the current configuration IS when it was working.

like image 472
Justin Avatar asked Oct 01 '15 17:10

Justin


1 Answers

It would seem that your error is actually in finding a class called ModuleWeaver. This class is part of the Fody package.

Just updating the package in nuget package manager with:

   update-package Fody -reinstall

Will probably fix it.

Failing that: make sure that your app.config file does not have incorrect redirects. Remove this section, remove all the redirects. Visual studio will typically add the necessary ones back.

  <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>

Try again, if that fails, try to find which dependent assembly is failing. You can write a one line command line app, or use LinqPad.

You can try LinqPad, if you don't use it already, paste this.

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

You should get an exception detailing the missing library.

like image 105
Jim Avatar answered Oct 13 '22 08:10

Jim