** 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.
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.
If you are using git, running this from the command line:
git clean -xdf
After trying all solutions I could find on the internet, the following worked for me:
Debug
and Release
folders in your PCL project and your {platform} project. For me these were located in something like MyPCLProjectName\bin\
and iOS\bin\iPhoneSimulator\
..csproj
file and remove all <Import>
tags, except for the one that starts <Import Project="$(MSBuildExtensionsPath32)\...
Solution Explorer > right-click solution > Restore NuGet Packages
. To debug such issues, you can use SysInternals Process Monitor.
The general approach is:
look for missing DLLs. This part is a bit tricky, since
So you need to find a DLL which was never found. And you don't want DLLs that were not found but then found in a subsequent attempt.
Well, that process can be quite time consuming, so I developed the tool Process Monitor Log Analyzer. With it, you should be able to find the culprit in less time.
Disclaimer: I am the author of that free tool, if that didn't become clear from the text.
Some of you getting similar errors might benefit from this info, which states that projects with different Fody versions cannot use the same NuGet packages folder (if I understood correctly): Installing multiple versions of PropertyChanged breaks compilation
Reinstalling the Fody package in all projects also resolves the issue, but changing all to the same version might be easier.
I had a project that encountered this: my machine had Visual Studio 2017
installed, but I had recently also installed the Build Tools for Visual Studio 2019
as well for an unrelated project. It looks like something became confused as to which build tools to use, since uninstalling the 2019 ones resolved this for me.
User contributions licensed under CC BY-SA 3.0