Interesting article that may be pertinent to CSLA: Fast method invoker without using reflection

Interesting article that may be pertinent to CSLA: Fast method invoker without using reflection

Old forum URL: forums.lhotka.net/forums/t/537.aspx


JCardina posted on Tuesday, July 04, 2006

"Method reflecting invoke is nice, but frequently do it can be too slow. This article describes an alternative method for dynamic method invoke."

http://www.codeproject.com/useritems/FastMethodInvoker.asp

One huge plus I see right away aside from the speed improvements is the elimination of the infamous "TargetInvocationException" that drove me batty when I first started out with CSLA.

But will it work with remoting?

ajj3085 replied on Wednesday, July 05, 2006

Well, its still using reflection (note the MethodInfo parameter), but its also using Emit to compile code in memory.  I think this would be worth looking into, since reflection seems to be a gripe for some that are concerned about performance (even though db access takes much more time).

RockfordLhotka replied on Wednesday, July 05, 2006

A reader named Gareth Edwards emailed me with some details about optimizing reflection a couple weeks ago. Not only that, but in .NET 2.0 there's also a DynamicMethod object that can be used to speed up access to private fields - a lot!

I do think that for a future 2.x version it makes all the sense in the world to optimize the reflection using these concepts. I can imagine changing UndoableBase and speeding up n-level undo radically. Similarly, OnUnknownPropertyChanged could be optimized to cache its findings, etc.

Whether this ends up in 2.1 or something later I can't say. I would like to get the updated validation/authorization rules functionality done (along with filteredbindinglist) within the next few weeks. If I get that done and still have time to build/test the reflection changes I will - otherwise they'll have to come later.

JCardina replied on Wednesday, July 05, 2006

RockfordLhotka:

I do think that for a future 2.x version it makes all the sense in the world to optimize the reflection using these concepts.

Interesting.  Hopefully once my current work load is down to a dull roar I can look at porting these changes back to the 1.x framework (under .net 2).  We started with 1.x CSLA and now we have a large app released using it and after looking at all the changes in the 2.x framework it looks like it's way too risky and time consuming to re-write a working and released business object layer to work with the 2.x framework, but hopefully I can port some critical and useful changes back to it down the road.

Cheers!

Copyright (c) Marimer LLC