© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
4 replies
Althos

Delegate.CreateDelegate returns "ArgumentException: method arguments are incompatible"

Any idea what I did wrong here ? My method seems to be of the correct type
        public void RegenerateEventEnums()
        {
            FieldInfo[] fields = typeof(Card).GetFields();
            foreach (FieldInfo field in fields)
            {
                var del = Delegate.CreateDelegate(typeof(Action<Card>), GetType().GetMethod("Test"));
            }
        }

        public void Test(Card card)
        {
            Debug.Log("My card!");
        }
        public void RegenerateEventEnums()
        {
            FieldInfo[] fields = typeof(Card).GetFields();
            foreach (FieldInfo field in fields)
            {
                var del = Delegate.CreateDelegate(typeof(Action<Card>), GetType().GetMethod("Test"));
            }
        }

        public void Test(Card card)
        {
            Debug.Log("My card!");
        }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

how to delegate on static method
C#CC# / help
16mo ago
❔ Building a delegate with a Type and a MethodInfo keeps throwing ArgumentException
C#CC# / help
3y ago
Inferring arguments to a method
C#CC# / help
2y ago
Expressing intent that method parameters are immutable for reference type arguments
C#CC# / help
3y ago