简体   繁体   中英

Fody is throwing an error after installation in my MVVM WPF project

I am trying to build an app using WPF based on the MVVM project. While learning, I found it tedious to have to implement the getter/setter for every property to notify the view of a change. That is when I learn about Fody

I tried to install the package using the following 2 commands

Install-Package PropertyChanged.Fody
Update-Package Fody

During the Install-Package PropertyChanged.Fody step, I got the following warnings

One or more packages could not be completely uninstalled: Fody.2.4.1. Restart Visual Studio to finish uninstall.

Then During the Update-Package Fody step, I got the following warnings

Uninstalling 'Fody 2.3.20'. Access to the path 'C:\\WinProjects\\Proj1\\packages\\Fody.2.3.20\\netclassictask\\Fody.dll' is denied. Access to the path 'C:\\WinProjects\\Proj1\\packages\\Fody.2.3.20\\netclassictask\\FodyCommon.dll' is denied. Access to the path 'Fody.dll' is denied. Successfully uninstalled 'Fody 2.3.20'. One or more packages could not be completely uninstalled: Fody.2.3.20. Restart Visual Studio to finish uninstall.

I tried running Visual Studio as Admin but that also lead me to the same results.

Now, when I build this project I get the following error

The "Fody.WeavingTask" task could not be loaded from the assembly C:\\WinProjects\\Proj1\\packages\\Fody.2.4.1\\build..\\netclassictask\\Fody.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. WindowsClient

How can I solve this problem?

I would first reboot your computer and then uninstall everything:

Get-Project -All | Uninstall-Package PropertyChanged.Fody -RemoveDependencies
Get-Project -All | Uninstall-Package Fody -RemoveDependencies

If necessary, repeat for both versions (Fody 2.3.20 and 2.4.1).

After you're done, install Fody again. If uninstalling isn't enough, delete all Fody files from C:\\WinProjects\\Proj1\\packages

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM