title: Exception when adding new method in a working Service using gRPC-Web and protobuf-net
body: <p>I am getting the following exception:</p>
  <blockquote>
  <p>Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
  Unhandled exception rendering component: The type initializer for 'DefaultProxyCache<code>1' threw an exception. System.TypeInitializationException: The type initializer for 'DefaultProxyCache</code>1' threw an exception. ---&gt; System.ArgumentException: Invalid generic arguments
  Parameter name: typeArguments
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.MakeGenericMethod_impl(System.Reflection.RuntimeMethodInfo,System.Type[])
  at System.Reflection.RuntimeMethodInfo.MakeGenericMethod (System.Type[] methodInstantiation) &lt;0x342def8 + 0x000d6&gt; in :0
  at ProtoBuf.Grpc.Internal.ContractOperation.TryGetClientHelper () [0x0001b] in /<em>/src/protobuf-net.Grpc/Internal/ContractOperation.cs:291
  at ProtoBuf.Grpc.Internal.ProxyEmitter.EmitFactory[TService] (ProtoBuf.Grpc.Configuration.BinderConfiguration binderConfig) [0x00477] in /</em>/src/protobuf-net.Grpc/Internal/ProxyEmitter.cs:238
  at ProtoBuf.Grpc.Internal.ProxyEmitter.CreateFactory[TService] (ProtoBuf.Grpc.Configuration.BinderConfiguration binderConfig) [0x0006d] in /<em>/src/protobuf-net.Grpc/Internal/ProxyEmitter.cs:123
  at ProtoBuf.Grpc.Configuration.ClientFactory+DefaultProxyCache`1[TService]..cctor () [0x00000] in /</em>/src/protobuf-net.Grpc/Configuration/ClientFactory.cs:81</p>
  </blockquote>
  <p>My project uses gRPC-Web, Blazor web assembly and protobuf-net</p>
  <p>This is my service contract:</p>
  <pre><code>[ServiceContract(Name = &quot;Services.Customer&quot;)]
  public interface ICustomerService
  {       
      ValueTask&lt;Customer&gt; CreateCustomer(Customer customerDTO);
  
      ValueTask&lt;CustomerResultSet&gt; GetCustomers();
  }
  </code></pre>
  <p>The implementation is:</p>
  <pre><code>public class CustomerService : ICustomerService
  {
      private readonly CustomerUseCases customerLogic;
  
      public CustomerService(CustomerUseCases customerLogic)
      {
          this.customerLogic = customerLogic;
      }
  
      public async ValueTask&lt;Customer&gt; CreateCustomer(Customer customerDTO)
      {
          var result = await customerLogic.CreateCustomer(customerDTO);
        
          return customerDTO;
      }
  
      public async ValueTask&lt;CustomerResultSet&gt; GetCustomers()
      {
          CustomerResultSet result = new CustomerResultSet { Customers = await customerLogic.GetCustomer() };
          return result;
      }
  }
  </code></pre>
  <p>As for the Datacontracts:</p>
  <pre><code>[DataContract]
  public class CustomerResultSet
  {
      [DataMember(Order = 1)]
      public IEnumerable&lt;Customer&gt; Customers { get; set; }
  }
  </code></pre>
  <p>And,</p>
  <pre><code>[DataContract]
  public partial class Customer
  {   
      [DataMember(Order = 1)]        
      public int CustomerId { get; set; }
      [DataMember(Order = 2)]        
      public string CustomerName { get; set; }
  }
  </code></pre>
  <p>Before I was returning a List of customers in the service but I realize I needed a class to model the message in order to protobuf-net be able to serialize that is why CustomerResultSet. Still, it is not working.
  Any help much appreciated</p>