Issues with IL2CPP and Reflection

Hello Everyone,
I am running into an issue with IL2CPP, I am using Reflection. My code is as following,

        public static void Inject(object obj)
        {
            BindingManager bindingManager = GameObject.FindObjectOfType<BindingManager>();
            if (bindingManager == null)
                return;
            Type type = obj.GetType();
            List<FieldInfo> fieldInfo = GetFields(type);
            foreach (FieldInfo f in fieldInfo)
            {
                Attribute[] attributes = f.GetCustomAttributes(false) as Attribute[];
                foreach (Attribute attr in attributes)
                {
                    if (attr is InjectSignal)
                    {
                        if (bindingManager._Bindings.ContainsKey(f.FieldType))
                            f.SetValue(obj, bindingManager._Bindings[f.FieldType]);
                        else
                            Debug.LogError("Inject-> Could not find binding for type : " + f.FieldType);
                    }
                }
            }
        }

In the above code, GetCustomAttributes function is returning null on the Android platform(I haven’t tried iOS yet ).
I created a link.xml as follows,

<?xml version="1.0" encoding="UTF-8"?>
<linker>
    <assembly fullname="System">
        <type fullname="System.Reflection" preserve="all" />
        <type fullname="System.Reflection.*" preserve="all" />
        <namespace fullname="System.Reflection" preserve="all" />
        <namespace fullname="System.Reflection.*" preserve="all" />
    </assembly>
</linker>

Any suggestion would be really helpful.

Maybe you also should add your attributes to link.xml ?

Thanks to my friend Sunil…
Problem was with type casting
Changing the following line
Attribute[ ] attributes = f.GetCustomAttributes(false) as Attribute[ ];

to

object[ ] attributes = f.GetCustomAttributes(false);

fixed the exception.