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

** This is a problem in Visual Studio 2013.

The error I get is massive and basically useless, but its essence 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 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' 

Since there have been no changes, I have no idea what the problem is. The DLL he is looking for sits in the same place where he always sat.

Edit: Apparently, at this moment, he was tired of spitting out this error so that it would fabricate 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:

In addition, the error is allegedly happening inside "Fody.targets" on line 50, which

 <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, reinstalled them during the build process. The error after this coincides with the second error:

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

Change 4:

I really hope that the developer Fody sees this because we are in absolute condition until it is fixed. We cannot "go back" when it was working, because the current configuration of IS was when it was working.

+7
c # fody fody-propertychanged
source share
5 answers

It would seem that your mistake is to find a class named ModuleWeaver . This class is part of the Fody package.

Just update the package in nuget package nuget with

  update-package Fody -reinstall 

This is most likely to be fixed.

Failed: make sure your app.config file does not have the wrong redirects. Delete this section, delete all redirects. A visual studio will usually add the ones you need.

  <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 this fails, try to find which dependent assembly is not working. You can write a single line command line application or use LinqPad.

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

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

You should get an exception describing the missing library.

+11
source share

To debug such problems, you can use SysInternals Process Monitor .

General approach:

  • run Process Monitor
  • apply a filter to monitor only your application
  • reproduce the problem.
  • Look for missing dll files. This part is a bit complicated since

    • DLL cannot be found several times ("Path not found")
    • but finally can be found ("Success")
    • it may not be the DLL you're looking for, but the dependency of that DLL

    So, you need to find a DLL that has never been . And you do not want the DLLs not to be found, but then were found in a subsequent attempt.

Well, this process can be quite time consuming, so I developed the Process Log Log Analyzer tool. With it, you can find the culprit in less time.

  • run Process Monitor
  • apply a filter to monitor only your application
  • reproduce the problem.
  • save the result as XML (save all elements, "path not found" and "success")
  • open XML in Log Analyzer
  • top to bottom, check for a dll. The tool will only display DLLs that will never be found.

Disclaimer: I am the author of this free tool, if it is not clear from the text.

+1
source share

Some of you who receive such errors may benefit from this information, which says that projects with different versions of Fody cannot use the same NuGet package folder (if I understood correctly): Installing multiple versions of compilation of PropertyChanged layouts

Reinstalling the Fody package in all projects also fixes the problem, but it may be easier to change everything to the same version.

+1
source share

After trying all the solutions that I could find on the Internet, the following worked for me:

  • Close Visual Studio.
  • Delete the Debug and Release folders in the PCL project and in the {platform} project. For me, they were located approximately like MyPCLProjectName\bin\ and iOS\bin\iPhoneSimulator\ .
  • Edit the PCL file and {platform} .csproj and remove all the <Import> tags except for the one that launches <Import Project="$(MSBuildExtensionsPath32)\...
  • Reopen Visual Studio.
  • Restore packages (this step can be performed automatically when you re-open Visual Studio) - Solution Explorer > right-click solution > Restore NuGet Packages .
+1
source share

If you are using git, run this from the command line:

 git clean -xdf 
+1
source share

All Articles