diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 3ee9104b1..cdd5fc210 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -2097,7 +2097,9 @@ private void GenerateVTableMethodDelegates(Class @class, Method method) WriteLine($"private static {method.FunctionType} {vTableMethodDelegateName}Instance;"); NewLine(); - + WriteLine("#if ENABLE_IL2CPP"); + WriteLine($"[AOT.MonoPInvokeCallback(typeof({method.FunctionType}))]"); + WriteLine("#endif"); using (WriteBlock($"private static {retType} {vTableMethodDelegateName}Hook({string.Join(", ", @params)})")) { WriteLine($@"var {Helpers.TargetIdentifier} = {@class.Visit(TypePrinter)}.__GetInstance({Helpers.InstanceField});");