dynamic type in IL2CPP

Hello. Can someone explain me why i can’t use dynamic keyword when compaile build in IL2CPP. Thank you.

Did you even TRY to google that question?! There is a LOT of answers about it.

You are NEVER gonna be the first guy to find a problem like this, NEVER.

Are you seruosly? I read all these posts before asking a question here. I know what Unity not support Dynamic when IL2CPP but i want to know reason. What happend when Unity compile C++ code from IL? If Unity doesnt supprot Dynamic for IL2CPP why not say an any word in documentation?

1 Like

Remember il2cpp is still a relatively new technology. The documentation may not be perfect. You should expect to rely on some user made documentation when using the latest technologies.

If you want a technical answer, this documentation from Unity (Unity - Manual: Scripting restrictions) explicitly says il2cpp cannot implement members of the Reflection.Emit namespace, and this article from Keith Rome, a well known expert on cross platform C# and software engineer at Microsoft (Why can't I use the "dynamic" C# keyword in Xamarin.iOS? - Atmosera) explains that the dynamic keyword relies on Reflection.Emit.

2 Likes

Thanks you very much for your answer. This is very useful information. Now I understand why it doesn’t work.
I’m surprised I didn’t find any mention of DLR in my favorite book about C# - “CLR via C#”.
Another interesting question. If the main reason is iOS restriction
why doesn’t this work for Android with IL2CPP?

The restriction is not specific to iOS. In general, IL2CPP is an ahead-of-time compiler/runtime. So it does not support System.Reflection.Emit on any platform, even platforms that allow just-in-time compilation.

1 Like

Thank you for answer