diff --git a/src/System.Management.Automation/engine/remoting/client/JobManager.cs b/src/System.Management.Automation/engine/remoting/client/JobManager.cs index 8585d296007..a81c5efdeff 100644 --- a/src/System.Management.Automation/engine/remoting/client/JobManager.cs +++ b/src/System.Management.Automation/engine/remoting/client/JobManager.cs @@ -81,51 +81,43 @@ internal void RegisterJobSourceAdapter(Type jobSourceAdapterType) Dbg.Assert(jobSourceAdapterType != null, "JobSourceAdapterType should never be called with null value."); object instance = null; - if (jobSourceAdapterType.FullName != null && jobSourceAdapterType.FullName.EndsWith("WorkflowJobSourceAdapter", StringComparison.OrdinalIgnoreCase)) + ConstructorInfo constructor = jobSourceAdapterType.GetConstructor(Type.EmptyTypes); + if (!constructor.IsPublic) { - MethodInfo method = jobSourceAdapterType.GetMethod("GetInstance"); - instance = method.Invoke(null, null); + string message = string.Format(CultureInfo.CurrentCulture, + RemotingErrorIdStrings.JobManagerRegistrationConstructorError, + jobSourceAdapterType.FullName); + throw new InvalidOperationException(message); } - else - { - ConstructorInfo constructor = jobSourceAdapterType.GetConstructor(Type.EmptyTypes); - if (!constructor.IsPublic) - { - string message = string.Format(CultureInfo.CurrentCulture, - RemotingErrorIdStrings.JobManagerRegistrationConstructorError, - jobSourceAdapterType.FullName); - throw new InvalidOperationException(message); - } - try - { - instance = constructor.Invoke(null); - } - catch (MemberAccessException exception) - { - _tracer.TraceException(exception); - throw; - } - catch (TargetInvocationException exception) - { - _tracer.TraceException(exception); - throw; - } - catch (TargetParameterCountException exception) - { - _tracer.TraceException(exception); - throw; - } - catch (NotSupportedException exception) - { - _tracer.TraceException(exception); - throw; - } - catch (SecurityException exception) - { - _tracer.TraceException(exception); - throw; - } + try + { + instance = constructor.Invoke(null); + } + catch (MemberAccessException exception) + { + _tracer.TraceException(exception); + throw; + } + catch (TargetInvocationException exception) + { + _tracer.TraceException(exception); + throw; + } + catch (TargetParameterCountException exception) + { + _tracer.TraceException(exception); + throw; + } + catch (NotSupportedException exception) + { + _tracer.TraceException(exception); + throw; + } + catch (SecurityException exception) + { + _tracer.TraceException(exception); + throw; } if (instance != null)