0

I'm trying to create classes dynamically to import XAML binding. It's working well in WPF, but not in Windows Phone 8. Apparently, Windows Phone 8 does not support binding to a dynamic data context (it just doesn't try to invoke any of the dynamic methods and properties).

So I thought I'd go the longer route, and emit classes dynamically. Unfortunately, I couldn't find any way to emit IL in Windows Phone 8. The System.Reflection.Emit namespace exists, but contains no emitter helper classe. System.AppDomain doesn't exist at all, so I can't create a new assembly to place my newly generated classes in.

I noticed DynamicMethod is supported, but I need to generate entire classes, not just an anonymous method here and there. Is IL emitting completely forbidden in Windows Phone 8?

zmbq
  • 38,013
  • 14
  • 101
  • 171
  • Check [rule 3.9](http://msdn.microsoft.com/en-us/library/windows/apps/hh694083.aspx) – Hans Passant Jul 14 '13 at 14:12
  • Hmmmm. I'm not going to violate the rule - There's no dynamically downloaded code, and the dynamic behavior doesn't interact with the Windows runtime. However, if Microsoft decided to enforce the rule by killing the ability to generate IL on the fly - I'm out of luck. – zmbq Jul 14 '13 at 14:37
  • @HansPassant that's for Windows 8, not Windows Phone 8. – Claus Jørgensen Jul 14 '13 at 16:41
  • That doesn't make any difference, these are store certification requirements. – Hans Passant Jul 14 '13 at 16:47

1 Answers1

2

Is IL emitting completely forbidden in Windows Phone 8?

Only almost. But a binding doesn't need to be dynamic in the first place. Bindings attempt to access a property of a object without knowing it's type, so even if you bound a System.Object as DataContext, you could still have {Binding SomeProperty} in your XAML.

Claus Jørgensen
  • 25,882
  • 9
  • 87
  • 150