I am trying to get rid of some references by using string representation of certain types. But compiler is not letting me do it the way I want in case of generic methods. I
You can't use a variable in the place of the generic type argument (between < and >). It has to be a type determined at compile time.
But in your example this is already the case. Can't you just use
foreach (var component in container.Components.OfType()) { ... }