The AbstractBindableWrapper is getting more and more difficult. I am facing a lot of problems regarding Windows Forms and WPF databinding and of course regarding Reflection.Emit. AOP is very cool but is not easy to implement. I've written a dynamic proxy generator which creates an assembly and classes inside it. The idea is to have a double proxy for every business object that needs to be bound to the UI.
- The first proxy extends the business object and implements the INotifyPropertyChanged interface. This proxy is created with the DynamicPropertyChangedProxy class. It has been a challenge to write that class.
- The second one uses the interception pattern and is generated by Castle.DynamicProxy2 and its purpose is to raise the PropertyChanged event everytime the bound properties are changed. This second extends from the first
Now the last problem I've found is the deserialization of a class that is contained within a dynamic assembly, that is, the deserialization of the proxies. I've found also the solution and implemented it. It is working fine.
"In general, the formatter, during deserialization, loads the assembly by calling Load or LoadWithPartialName and because of which CLR will not find a dynamic assembly. One solution is to provide an event handler for AppDomain.CurrentDomain.AssemblyResolve event which gets called whenever the formatter fails to load an assembly. The identity of the assembly that failed during load is passed to this method. Your event handler can use the name to construct a path where the assembly file is available and use Assembly.LoadFrom(assemblyPath) to return Assembly."
1: public static Assembly OnAssemblyResolve(Object sender, ResolveEventArgs args)
3: if (args.Name.StartsWith(DYNAMIC_MOD_NAME))
5: return Assembly.GetAssembly(MyAssemblyBuilder.GetTypes());
7: return null;
The idea is to release Boxerp 0.2 within a month including all this stuff and these posts are part of the documentation.