1

I have a 'SourceClass' class with the simple C# method:

public bool TryGetSection<T>(out T result) where T : class, new()
{ //do something and return true/false }

and I'd like to execute it from powershell code.

$_config = New-Object [SourceClass]
$method = [SourceClass].GetMethod("TryGetSection")
$genericMethod = $method.MakeGenericMethod([AuthenticationProviderTypeConfig])
$authenticationProviderTypeConfig = New-Object AuthenticationProviderTypeConfig
$genericMethod.Invoke($_config, $authenticationProviderTypeConfig)
$authenticationProviderType = $authenticationProviderTypeConfig.Type

After execution, I'm expecting that the $authenticationProviderType will be filled, but it isn't. I'm just getting an empty string. I suppose I miss something. Is it possible to call generic method that has 'out' parameter? Thanks.

Andrei Orlov
  • 858
  • 3
  • 12
  • 24
  • possible duplicate of [How to call method with output parameters in Powershell?](http://stackoverflow.com/questions/821744/how-to-call-method-with-output-parameters-in-powershell) – Duncan Jul 18 '14 at 14:54
  • @Duncan, it isn't a duplicate, because my question is about how to execute a method that is generic and has 'out' parameter. – Andrei Orlov Jul 18 '14 at 15:24

0 Answers0