On 7/23/07, Fabian Schmied <[EMAIL PROTECTED]> wrote:

In your particular case, your development machine seems to be more
gracious regarding a subtle bug: you don't correctly associate the
generic parameters of your base type with those of your derived type.
With System.Reflection.Emit, this association does not come implicitly
from the parameter names, it must be explicitly specified by calling
MakeGenericType on the base type, specifying the
GenericParameterBuilders of the derived type.

I've updated your sample, which now works as intended on my machine, see
below.


Sure enough, that seems to do the trick. Thanks! We've been, erm, hacking at
this mostly successfully, but I don't think we would've ever figured this
out without someone pointing us to it. Google never showed people deriving
generic types from generic types, which is specifically the problem we had.

There is another issue I've noticed (of course, this is only a quick
sample, but just for completeness): You are assuming that if you get
any generic arguments back from the typeToWrap, then your derived type
should also be generic.


That's a quirk of how we're using it. We're using the wrapper classes to do
method interception in a dependency injection container, so I know that
we're always wrapping the pure generic version (i.e., always Foo<> and never
Foo<int>).

Thanks again,
Brad

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to