IL2CPP Compiled Application's scripts not working

I wanted to use IL2CPP in my application to make it more performant and also harder to decompile, but whenever I compiled my game using IL2CPP, some scripts are not functining properly (Mainly ones involved in raycasting and copying components from one gameobject to another). I believe it has something to do with AOT compilation, the LOW Managed Code Stripping and or that some of my script’s components are obtained via the scripts. If you have a better understanding of how IL2CPP works, please let me know what could have possibly caused this to happen.

I figured out that the error had been occurring because of the method that I was using for copying a TrailRenderer to another gameobject.

public static TrailRenderer CopyTrailRenderer(this GameObject obj, TrailRenderer duplicate)
    TrailRenderer target = obj.AddComponent<TrailRenderer>();
    foreach (PropertyInfo x in typeof(TrailRenderer).GetProperties())
        if (x.CanWrite)
            x.SetValue(target, x.GetValue(duplicate));
    return target;

The error was occurring on the x.SetValue line and the error message was “Get Method not found for ‘some TrailRenderer property’”. I fixed this by manually getting and setting the properties for the TrailRenderer.