question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not inject EventInvoker method

See original GitHub issue

This 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:

  1. Create a blank Xamarin.Forms application (netstandard 2.0 in this case).
  2. Add PropertyChanged 2.5.6 package, adding Fody 3.0.3.
  3. Add FodyWeavers.xml to projects, add weaver <PropertyChanged/> or <PropertyChanged EventInvokerNames="RaisePropertyChanged" />.
  4. 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:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ltrzesniewskicommented, May 14, 2018

@arnemolland Ok so I’ve installed Xamarin and tested your repro.

You’ve used the following config:

<?xml version="1.0" encoding="utf-8"?>
<Weavers>
    <PropertyChanged EventInvokerNames="RaisePropertyChanged" />
</Weavers>

But the issue here is that App inherits from Application which ultimately inherits from BindableObject which implements INotifyPropertyChanged, but it declares an event invoker named OnPropertyChanged.

=> if you put EventInvokerNames="OnPropertyChanged" in your config or if you remove the EventInvokerNames attribute altogether, the project compiles just fine.

0reactions
ltrzesniewskicommented, May 19, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found