Not sure why the factory is written the way it is, but you can get to the IEngineContext by simply referring to CurrentContext property of your base class (AbstractHelper).
--- Patrick Steele http://weblogs.asp.net/psteele On Fri, Nov 26, 2010 at 4:44 AM, Tomek Pluskiewicz <[email protected]> wrote: > Hi > > I have just attempted to create a small helper with access to the > current IEngineContext. So, I inherited AbstractHelper gave it one > constructor: > > public QuerystringHelper(IEngineContext engineContext) : > base(engineContext) {...} > > That results in [MissingMethodException: No parameterless constructor > defined for this object.] thrown in DefaultHelperFactory. "Why is > that?" I thought. > > So I looked into the factory and it turns out that > > ConstructorInfo constructorInfo = > helperType.GetConstructor(BindingFlags.Public, null, new Type[] > {typeof(IEngineContext)}, null); > > returns null and thus DefaultHelperFactory falls back to invoking the > parameterless constructor which I don't have (and I don't want it). > > This whole thing got me pretty confused. Why isn't GetConstructor > actually getting the right method? The same thing happens to the built- > in helpers when I run the GetConstructor method. On the other hand > running GetConstructor(new Type[] {typeof(IEngineContext)}) does work > as expected. > > Can anyone tell me what is going on? > > Regards > Tomasz > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/castle-project-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
