Monotouch deploy error:
if I use System.Reflection ( I think that is the reason)
I get the following error when I try to deploy
Could not link assemblies: Mono.Linker.ResolutionException: Can not resolve reference: System.Reflection.Emit.AssemblyBuilder at Mono.Linker.Steps.MarkStep.ResolveTypeDefinition (Mono.Cecil.TypeReference type) [0x00000] in :0 at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00000] in :0 at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00000] in :0 at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in :0 at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00000] in :0 at Mono.Linker.Steps.MarkStep.Process () [0x开发者_如何学Python00000] in :0 at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in :0 at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in :0 at MonoTouch.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in :0
Everything works fine in Simulator. If I don't use the library, I can deploy the app with no issues.
System.Reflection.Emit is not supported by Monotouch. It is because all the code must be existing in the binary and is actually linked by the linker after being created by ahead of time compiler. If you will be emitting the code from C# there is no way how it gets compiled on runtime to binary code as there is no full .NET runtime on iPhone.
Anyway, even if there would be a way how to compile on runtime to binary and link it (very complex issue BTW) this would violate Apple's approval guidelines, where it says that Apps cannot download code of any sort and change its behaviour on the fly.
So all in all, avoid reflection as such.
精彩评论