Could not inject EventInvoker method
See original GitHub issueThis issue seems to be the same as in #316 and is as of now present in PropertyChanged 2.5.6 / Fody 3.0.3 when used in Xamarin.Forms solutions, temporary workaround has been to downgrade the respective packages to 2.2.10 and 2.5.0. Minimal repro has been uploaded here. I’ve yet to test this issue on a Windows PC, however both VSMac and msbuild fails. I’m currently on Xamarin.Forms 3.0.0.446417.
Steps to reproduce:
- Create a blank Xamarin.Forms application (netstandard 2.0 in this case).
- Add PropertyChanged 2.5.6 package, adding Fody 3.0.3.
- Add FodyWeavers.xml to projects, add weaver
<PropertyChanged/>
or<PropertyChanged EventInvokerNames="RaisePropertyChanged" />
. - Build either with VS or msbuild.
Full msbuild log:
MSBUILD : error : Fody: An unhandled exception occurred:
MSBUILD : error : Exception:
MSBUILD : error : Failed to execute weaver /Users/arnemolland/.nuget/packages/propertychanged.fody/2.5.6/netclassicweaver/PropertyChanged.Fody.dll
MSBUILD : error : Type:
MSBUILD : error : System.Exception
MSBUILD : error : StackTrace:
MSBUILD : error : at InnerWeaver.ExecuteWeavers () [0x0007a] in C:\projects\fody\FodyIsolated\InnerWeaver.cs:208
MSBUILD : error : at InnerWeaver.Execute () [0x0004d] in C:\projects\fody\FodyIsolated\InnerWeaver.cs:103
MSBUILD : error : Source:
MSBUILD : error : FodyIsolated
MSBUILD : error : TargetSite:
MSBUILD : error : Void ExecuteWeavers()
MSBUILD : error : Could not inject EventInvoker method on type 'FodyRepro.App'. It is possible you are inheriting from a base class and have not correctly set 'EventInvokerNames' or you are using a explicit PropertyChanged event and the event field is not visible to this instance. Either correct 'EventInvokerNames' or implement your own EventInvoker on this class. If you want to suppress this place a [DoNotNotifyAttribute] on FodyRepro.App.
MSBUILD : error : Type:
MSBUILD : error : Fody.WeavingException
MSBUILD : error : StackTrace:
MSBUILD : error : at ModuleWeaver.InjectMethod (Mono.Cecil.TypeDefinition targetType, InvokerTypes& invokerType) [0x0005e] in C:\projects\propertychanged\PropertyChanged.Fody\MethodInjector.cs:102
MSBUILD : error : at ModuleWeaver.AddOnPropertyChangedMethod (Mono.Cecil.TypeDefinition targetType) [0x0005c] in C:\projects\propertychanged\PropertyChanged.Fody\MethodInjector.cs:28
MSBUILD : error : at ModuleWeaver.FindMethodsForNodes () [0x00026] in C:\projects\propertychanged\PropertyChanged.Fody\MethodFinder.cs:237
MSBUILD : error : at ModuleWeaver.Execute () [0x00042] in C:\projects\propertychanged\PropertyChanged.Fody\ModuleWeaver.cs:18
MSBUILD : error : at InnerWeaver.ExecuteWeavers () [0x0006b] in C:\projects\fody\FodyIsolated\InnerWeaver.cs:204
MSBUILD : error : Source:
MSBUILD : error : PropertyChanged.Fody
MSBUILD : error : TargetSite:
MSBUILD : error : Mono.Cecil.MethodDefinition InjectMethod(Mono.Cecil.TypeDefinition, InvokerTypes ByRef)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Fody.PropertyChanged - Could not inject EventInvoker ...
when the base View Model is in the same project, then the "OnPropertyChanged" method can be injected into that class.
Read more >Could not inject EventInvoker method on type · Issue #316
It is possible you are inheriting from a base class and have not correctly set 'EventInvokerNames' or you are using a explicit PropertyChanged ......
Read more >Developers - Could not inject EventInvoker method -
Could not inject EventInvoker method ... This issue seems to be the same as in #316 and is as of now present in...
Read more >Avalonia controls inherit from INotifyPropertyChanged but ...
Could not inject EventInvoker method on type 'Cyclops.UI.Main.MainView'. It is possible you are inheriting from a base class and have not ...
Read more >Fody - INotifyPropertyChanged the easy way
Let's talk about how to set this up. There are 3 simple steps. 1.Nuget. The first step is to add the nuget package....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@arnemolland Ok so I’ve installed Xamarin and tested your repro.
You’ve used the following config:
But the issue here is that
App
inherits fromApplication
which ultimately inherits fromBindableObject
which implementsINotifyPropertyChanged
, but it declares an event invoker namedOnPropertyChanged
.=> if you put
EventInvokerNames="OnPropertyChanged"
in your config or if you remove theEventInvokerNames
attribute altogether, the project compiles just fine.You’re welcome. Your repro compiled fine when I removed the attribute, so if you manage to extract an example which fails without the attribute, feel free to post it.