title: Injection Error : Configuration files are not supported. at System.ServiceModel.ClientBase`1..ctor() In Asp .Net5
body: <p>I am programming a .NET project. I have a problem with this project. I have to use a web service that does not have a document. These classes are automatically generated and brought from the old project.</p>
  <pre><code>using System.CodeDom.Compiler;
  using System.ComponentModel;
  using System.Diagnostics;
  using System.ServiceModel;
  using System.ServiceModel.Channels;
  using System.Threading.Tasks;
  
  namespace Nap.Api.Statement.Services.Services {
      
      
      [GeneratedCodeAttribute(&quot;System.ServiceModel&quot;, &quot;4.0.0.0&quot;)]
      [ServiceContractAttribute(Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, ConfigurationName=&quot;SmartCardService.PKG_RMTO_WSPortType&quot;)]
      public interface PKG_RMTO_WSPortType {
          
          // CODEGEN: Generating message contract since the wrapper name (SVARCHAR2-RMTO_WEB_SERVICESInput) of message RMTO_WEB_SERVICESRequest does not match the default value (RMTO_WEB_SERVICES)
          [OperationContractAttribute(Action=&quot;RMTO_WEB_SERVICES&quot;, ReplyAction=&quot;*&quot;)]
          RMTO_WEB_SERVICESResponse RMTO_WEB_SERVICES(RMTO_WEB_SERVICESRequest request);
          
          [OperationContractAttribute(Action=&quot;RMTO_WEB_SERVICES&quot;, ReplyAction=&quot;*&quot;)]
          Task&lt;RMTO_WEB_SERVICESResponse&gt; RMTO_WEB_SERVICESAsync(RMTO_WEB_SERVICESRequest request);
      }
      
      [DebuggerStepThroughAttribute()]
      [GeneratedCodeAttribute(&quot;System.ServiceModel&quot;, &quot;4.0.0.0&quot;)]
      [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
      [MessageContractAttribute(WrapperName=&quot;SVARCHAR2-RMTO_WEB_SERVICESInput&quot;, WrapperNamespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, IsWrapped=true)]
      public partial class RMTO_WEB_SERVICESRequest {
          
          [MessageBodyMemberAttribute(Name=&quot;IN_USERNAME-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=0)]
          public string IN_USERNAMEVARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_SERVICEID-NUMBER-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=1)]
          public double IN_SERVICEIDNUMBERIN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PASSWORD-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=2)]
          public string IN_PASSWORDVARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_9-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=3)]
          public string IN_PARAM_9VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_8-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=4)]
          public string IN_PARAM_8VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_7-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=5)]
          public string IN_PARAM_7VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_6-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=6)]
          public string IN_PARAM_6VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_5-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=7)]
          public string IN_PARAM_5VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_4-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=8)]
          public string IN_PARAM_4VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_3-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=9)]
          public string IN_PARAM_3VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_2-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=10)]
          public string IN_PARAM_2VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_10-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=11)]
          public string IN_PARAM_10VARCHAR2IN;
          
          [MessageBodyMemberAttribute(Name=&quot;IN_PARAM_1-VARCHAR2-IN&quot;, Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=12)]
          public string IN_PARAM_1VARCHAR2IN;
          
          public RMTO_WEB_SERVICESRequest() {
          }
          
          public RMTO_WEB_SERVICESRequest(string IN_USERNAMEVARCHAR2IN, double IN_SERVICEIDNUMBERIN, string IN_PASSWORDVARCHAR2IN, string IN_PARAM_9VARCHAR2IN, string IN_PARAM_8VARCHAR2IN, string IN_PARAM_7VARCHAR2IN, string IN_PARAM_6VARCHAR2IN, string IN_PARAM_5VARCHAR2IN, string IN_PARAM_4VARCHAR2IN, string IN_PARAM_3VARCHAR2IN, string IN_PARAM_2VARCHAR2IN, string IN_PARAM_10VARCHAR2IN, string IN_PARAM_1VARCHAR2IN) {
              this.IN_USERNAMEVARCHAR2IN = IN_USERNAMEVARCHAR2IN;
              this.IN_SERVICEIDNUMBERIN = IN_SERVICEIDNUMBERIN;
              this.IN_PASSWORDVARCHAR2IN = IN_PASSWORDVARCHAR2IN;
              this.IN_PARAM_9VARCHAR2IN = IN_PARAM_9VARCHAR2IN;
              this.IN_PARAM_8VARCHAR2IN = IN_PARAM_8VARCHAR2IN;
              this.IN_PARAM_7VARCHAR2IN = IN_PARAM_7VARCHAR2IN;
              this.IN_PARAM_6VARCHAR2IN = IN_PARAM_6VARCHAR2IN;
              this.IN_PARAM_5VARCHAR2IN = IN_PARAM_5VARCHAR2IN;
              this.IN_PARAM_4VARCHAR2IN = IN_PARAM_4VARCHAR2IN;
              this.IN_PARAM_3VARCHAR2IN = IN_PARAM_3VARCHAR2IN;
              this.IN_PARAM_2VARCHAR2IN = IN_PARAM_2VARCHAR2IN;
              this.IN_PARAM_10VARCHAR2IN = IN_PARAM_10VARCHAR2IN;
              this.IN_PARAM_1VARCHAR2IN = IN_PARAM_1VARCHAR2IN;
          }
      }
      
      [DebuggerStepThroughAttribute()]
      [GeneratedCodeAttribute(&quot;System.ServiceModel&quot;, &quot;4.0.0.0&quot;)]
      [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
      [MessageContractAttribute(WrapperName=&quot;RMTO_WEB_SERVICESOutput&quot;, WrapperNamespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, IsWrapped=true)]
      public partial class RMTO_WEB_SERVICESResponse {
          
          [MessageBodyMemberAttribute(Namespace=&quot;http://xmlns.oracle.com/orawsv/TR_PUBLIC_WS/PKG_RMTO_WS&quot;, Order=0)]
          public string RETURN;
          
          public RMTO_WEB_SERVICESResponse() {
          }
          
          public RMTO_WEB_SERVICESResponse(string RETURN) {
              this.RETURN = RETURN;
          }
      }
      
      [GeneratedCodeAttribute(&quot;System.ServiceModel&quot;, &quot;4.0.0.0&quot;)]
      public interface PKG_RMTO_WSPortTypeChannel : PKG_RMTO_WSPortType, IClientChannel {
      }
      
      [DebuggerStepThroughAttribute()]
      [GeneratedCodeAttribute(&quot;System.ServiceModel&quot;, &quot;4.0.0.0&quot;)]
      public partial class PKG_RMTO_WSPortTypeClient : ClientBase&lt;PKG_RMTO_WSPortType&gt;, PKG_RMTO_WSPortType {
          
          public PKG_RMTO_WSPortTypeClient() {
          }
          
          public PKG_RMTO_WSPortTypeClient(string endpointConfigurationName) : 
                  base(endpointConfigurationName) {
          }
          
          public PKG_RMTO_WSPortTypeClient(string endpointConfigurationName, string remoteAddress) : 
                  base(endpointConfigurationName, remoteAddress) {
          }
          
          public PKG_RMTO_WSPortTypeClient(string endpointConfigurationName, EndpointAddress remoteAddress) : 
                  base(endpointConfigurationName, remoteAddress) {
          }
          
          public PKG_RMTO_WSPortTypeClient(Binding binding, EndpointAddress remoteAddress) : 
                  base(binding, remoteAddress) {
          }
          
          [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
          RMTO_WEB_SERVICESResponse PKG_RMTO_WSPortType.RMTO_WEB_SERVICES(RMTO_WEB_SERVICESRequest request) {
              return base.Channel.RMTO_WEB_SERVICES(request);
          }
          
          public string RMTO_WEB_SERVICES(string IN_USERNAMEVARCHAR2IN, double IN_SERVICEIDNUMBERIN, string IN_PASSWORDVARCHAR2IN, string IN_PARAM_9VARCHAR2IN, string IN_PARAM_8VARCHAR2IN, string IN_PARAM_7VARCHAR2IN, string IN_PARAM_6VARCHAR2IN, string IN_PARAM_5VARCHAR2IN, string IN_PARAM_4VARCHAR2IN, string IN_PARAM_3VARCHAR2IN, string IN_PARAM_2VARCHAR2IN, string IN_PARAM_10VARCHAR2IN, string IN_PARAM_1VARCHAR2IN) {
              RMTO_WEB_SERVICESRequest inValue = new RMTO_WEB_SERVICESRequest();
              inValue.IN_USERNAMEVARCHAR2IN = IN_USERNAMEVARCHAR2IN;
              inValue.IN_SERVICEIDNUMBERIN = IN_SERVICEIDNUMBERIN;
              inValue.IN_PASSWORDVARCHAR2IN = IN_PASSWORDVARCHAR2IN;
              inValue.IN_PARAM_9VARCHAR2IN = IN_PARAM_9VARCHAR2IN;
              inValue.IN_PARAM_8VARCHAR2IN = IN_PARAM_8VARCHAR2IN;
              inValue.IN_PARAM_7VARCHAR2IN = IN_PARAM_7VARCHAR2IN;
              inValue.IN_PARAM_6VARCHAR2IN = IN_PARAM_6VARCHAR2IN;
              inValue.IN_PARAM_5VARCHAR2IN = IN_PARAM_5VARCHAR2IN;
              inValue.IN_PARAM_4VARCHAR2IN = IN_PARAM_4VARCHAR2IN;
              inValue.IN_PARAM_3VARCHAR2IN = IN_PARAM_3VARCHAR2IN;
              inValue.IN_PARAM_2VARCHAR2IN = IN_PARAM_2VARCHAR2IN;
              inValue.IN_PARAM_10VARCHAR2IN = IN_PARAM_10VARCHAR2IN;
              inValue.IN_PARAM_1VARCHAR2IN = IN_PARAM_1VARCHAR2IN;
              RMTO_WEB_SERVICESResponse retVal = ((PKG_RMTO_WSPortType)(this)).RMTO_WEB_SERVICES(inValue);
              return retVal.RETURN;
          }
          
          [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
          Task&lt;RMTO_WEB_SERVICESResponse&gt; PKG_RMTO_WSPortType.RMTO_WEB_SERVICESAsync(RMTO_WEB_SERVICESRequest request) {
              return base.Channel.RMTO_WEB_SERVICESAsync(request);
          }
          
          public Task&lt;RMTO_WEB_SERVICESResponse&gt; RMTO_WEB_SERVICESAsync(string IN_USERNAMEVARCHAR2IN, double IN_SERVICEIDNUMBERIN, string IN_PASSWORDVARCHAR2IN, string IN_PARAM_9VARCHAR2IN, string IN_PARAM_8VARCHAR2IN, string IN_PARAM_7VARCHAR2IN, string IN_PARAM_6VARCHAR2IN, string IN_PARAM_5VARCHAR2IN, string IN_PARAM_4VARCHAR2IN, string IN_PARAM_3VARCHAR2IN, string IN_PARAM_2VARCHAR2IN, string IN_PARAM_10VARCHAR2IN, string IN_PARAM_1VARCHAR2IN) {
              RMTO_WEB_SERVICESRequest inValue = new RMTO_WEB_SERVICESRequest();
              inValue.IN_USERNAMEVARCHAR2IN = IN_USERNAMEVARCHAR2IN;
              inValue.IN_SERVICEIDNUMBERIN = IN_SERVICEIDNUMBERIN;
              inValue.IN_PASSWORDVARCHAR2IN = IN_PASSWORDVARCHAR2IN;
              inValue.IN_PARAM_9VARCHAR2IN = IN_PARAM_9VARCHAR2IN;
              inValue.IN_PARAM_8VARCHAR2IN = IN_PARAM_8VARCHAR2IN;
              inValue.IN_PARAM_7VARCHAR2IN = IN_PARAM_7VARCHAR2IN;
              inValue.IN_PARAM_6VARCHAR2IN = IN_PARAM_6VARCHAR2IN;
              inValue.IN_PARAM_5VARCHAR2IN = IN_PARAM_5VARCHAR2IN;
              inValue.IN_PARAM_4VARCHAR2IN = IN_PARAM_4VARCHAR2IN;
              inValue.IN_PARAM_3VARCHAR2IN = IN_PARAM_3VARCHAR2IN;
              inValue.IN_PARAM_2VARCHAR2IN = IN_PARAM_2VARCHAR2IN;
              inValue.IN_PARAM_10VARCHAR2IN = IN_PARAM_10VARCHAR2IN;
              inValue.IN_PARAM_1VARCHAR2IN = IN_PARAM_1VARCHAR2IN;
              return ((PKG_RMTO_WSPortType)(this)).RMTO_WEB_SERVICESAsync(inValue);
          }
      }
  }
  </code></pre>
  <p>My problem is that I want to inject this into my startup project. But I can not. The code already exists and is correct: based on Asp MVC</p>
  <pre><code>container.Register&lt;PKG_RMTO_WSPortType&gt;(() =&gt; new PKG_RMTO_WSPortTypeClient(), Lifestyle.Scoped);
  </code></pre>
  <p>I will receive the codes I tested in the new project and the error:</p>
  <pre><code>    services.TryAddSingleton&lt;PKG_RMTO_WSPortType&gt;(new PKG_RMTO_WSPortTypeClient());
      services.TryAddScoped&lt;PKG_RMTO_WSPortType, PKG_RMTO_WSPortTypeClient&gt;();
  </code></pre>
  <p>Error:</p>
  <blockquote>
  <pre><code>System.PlatformNotSupportedException: Configuration files are not supported.
     at System.ServiceModel.ClientBase`1..ctor()
     at Nap.Api.Statement.Services.Services.PKG_RMTO_WSPortTypeClient..ctor()
  </code></pre>
  <p>in
  D:\Project\Safar724\Nap.Api.Statement\Layer\Nap.Api.Statement.Services\Connected
  Services\SmartCardService\Reference.cs:line 113
  at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean
  wrapExceptions)
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
  constructorCallSite, RuntimeResolverContext context)
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<code>2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor</code>2.VisitCallSite(ServiceCallSite
  callSite, TArgument argument)
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
  constructorCallSite, RuntimeResolverContext context)
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<code>2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor</code>2.VisitCallSite(ServiceCallSite
  callSite, TArgument argument)
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite
  callSite, ServiceProviderEngineScope scope)
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.&lt;&gt;c__DisplayClass1_0.b__0(ServiceProviderEngineScope
  scope)
  at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider
  sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
  at lambda_method24(Closure , IServiceProvider , Object[] )
  at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.&lt;&gt;c__DisplayClass4_0.b__0(ControllerContext
  controllerContext)
  at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.&lt;&gt;c__DisplayClass5_0.g__CreateController|0(ControllerContext
  controllerContext)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State&amp;
  next, Scope&amp; scope, Object&amp; state, Boolean&amp; isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
  --- End of stack trace from previous location ---
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker
  invoker, Task lastTask, State next, Scope scope, Object state, Boolean
  isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed
  context)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State&amp;
  next, Scope&amp; scope, Object&amp; state, Boolean&amp; isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
  --- End of stack trace from previous location ---
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker
  invoker, Task task, IDisposable scope)
  at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint
  endpoint, Task requestTask, ILogger logger)
  at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext
  httpContext)
  at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext
  httpContext, ISwaggerProvider swaggerProvider)
  at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext
  context)
  at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext
  context)
  at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext
  context)
  at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext
  context)</p>
  </blockquote>