0

I've been using PropertyChanged.Fody for years.

Now I want to also intercept PropertyChanging (to disallow certain property changes). So I installed PropertyChanging.Fody, but it caused errors. So I uninstalled and deleted anything related to Fody in my projects, and reinstalled only PropertyChanging.Fody. Still I get an error.

I'm not even using or implementing anything Fody in my project currently. I just installed and already I can't compile. Here is the error I get:

1>MSBUILD : warning FodyPackageReference: Fody: The package reference for PropertyChanging.Fody does not contain PrivateAssets='All' 1>MSBUILD : error : Fody: An unhandled exception occurred: 1>MSBUILD : error : Exception: 1>MSBUILD : error : Failed to execute weaver C:\Users\y2.nuget\packages\propertychanging.fody\1.30.3\build..\weaver\PropertyChanging.Fody.dll 1>MSBUILD : error : Type: 1>MSBUILD : error : System.Exception 1>MSBUILD : error : StackTrace: 1>MSBUILD : error : at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 222 1>MSBUILD : error : at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 113 1>MSBUILD : error : Source: 1>MSBUILD : error : FodyIsolated 1>MSBUILD : error : TargetSite: 1>MSBUILD : error : Void ExecuteWeavers() 1>MSBUILD : error : Object reference not set to an instance of an object. 1>MSBUILD : error : Type: 1>MSBUILD : error : System.NullReferenceException 1>MSBUILD : error : StackTrace: 1>MSBUILD : error : at ModuleWeaver.HasPropertyChangingEvent(TypeDefinition typeDefinition) 1>MSBUILD : error : at ModuleWeaver.HierarchyImplementsINotify(TypeReference typeReference) 1>MSBUILD : error : at ModuleWeaver.HierarchyImplementsINotify(TypeReference typeReference) 1>MSBUILD : error : at ModuleWeaver.PopulateINotifyNodes(List`1 typeNodes) 1>MSBUILD : error : at ModuleWeaver.BuildTypeNodes() 1>MSBUILD : error : at ModuleWeaver.Execute() 1>MSBUILD : error :
at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 186 1>MSBUILD : error : Source: 1>MSBUILD : error : PropertyChanging.Fody 1>MSBUILD : error : TargetSite: 1>MSBUILD : error : Boolean HasPropertyChangingEvent(Mono.Cecil.TypeDefinition) 1>MSBUILD : error : 1>Done building project "General.vbproj" -- FAILED.

I have 2 Projects. a vase project called "General". and another Project called MyPhone which references General. I installed to both projects. and both give the same error.

The weavers were created in both projects and seem okay.

Deleting bin/obj and cleaning solution multiple times makes no difference.

What can the issue be?

In the end of course I need both. Also PropertyChanging and aslo PropertyChanged.

I'd appreciate any help

Thanks in Advance

Additional Info

This is my regular weavers I've always used:

<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged CheckForEquality="false"/>
</Weavers>

If I just add <PropertyChanging />, then I get an error:

Fody: No weavers found for the configuration entries PropertyChanging. Add the desired weavers via their nuget package.

And if I go ahead and install ProperrtyChanging.Fody, Then I get again the above long error about ExecuteWeavers.

2 Answers 2

1

tl;dr - add the following to the vbproj file via a text editor:

<Reference Include="Microsoft.VisualBasic" />

EDIT: since the first version of this answer, this is now included in the official wiki of the repo.


Details:

After some research, this seems to be a bug / undocumented requirement when using PropertyChanging.Fody with a VB.NET project (but not C#) on .NET Framework (tested with 4.8). It doesn't happen with .NET Core / .NET5+.

It's related to the issue of the project not providing all the required references to MSBuild in a way that Fody can use: https://github.com/Fody/PropertyChanged/issues/313

No actual code is required to reproduce it, a fresh vb project based on .NET Framework 4.8 with added PropertyChanging.Fody NuGet package will not compile, regardless of the version of the nuget package or of Fody itself (tested with all versions Fody 1.x.x - 6.x.x). Same with a c# project.

I'll report the issue to the developers. In the meantime, the workaround is to manually add the missing requirements. In my case, and for a VB project, this included first the following two to even get to your error:

<Reference Include="System" />
<Reference Include="mscorlib" />

And then this one to solve it:

<Reference Include="Microsoft.VisualBasic" />
Sign up to request clarification or add additional context in comments.

8 Comments

Worked like a charm! Thanks! but now CheckForEquality="false" has lost its effect. PropertyChanged is now raised only when I set a property to a different value then it was before. I need it to be raised even when set to same value.
@YisroelM.Olewski - this seems to be a bug in PropertyChanged.Fody. I opened a github issue for it link.
Oh wow. You certainly put in a lot of work here. I went through the links and the documentation. I didn't quite understand everything. Is adding CheckForEquality=False in PropertyChanging supposed to help? I tried adding it, but it did not seem to change anything. Thanks!
@YisroelM.Olewski - it's still an open pull request, meaning it hasn't yet been merged into the repository. You'll be only able to use once the authors publish the version including this on nuget, and you upgrade your deps to the new version.
Hi. Thanks. Where can I see whats the status with this issue? Thanks!
|
0

Could you check below configuration,

Check for FodyWeavers.xml: • Ensure that a FodyWeavers.xml file exists in the root directory of each project. • This file should include the following configuration:

<Weavers> <PropertyChanging /> </Weavers>

1 Comment

Hi. Thanks! Please see the additional info I just added to my post. I'd appreciate any help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.