Skip to content

ServiceJsonRpcDescriptor.JsonRpcConnection.ConstructRpcClient<T> fails to create an instance #789

@tmat

Description

@tmat

When called with an interface that implements another interface like so TypeLoadException is thrown.

Assembly1:

internal class C
{
  internal interface ICallback : I
  {
  }
}

Assembly2:

[assembly: InternalsVisibleTo("Assembly1")]

internal interface I
{
   ValueTask<E> Get(D d, CancellationToken token);
}

internal class D
{
}

internal class E
{
}
Feature 'Convert tuple to struct refactoring' is currently unavailable due to an internal error. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Access is denied: 'D'.
       at System.Reflection.Emit.TypeBuilder.TermCreateClass(RuntimeModule module, Int32 tk, ObjectHandleOnStack type)
       at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
       at System.Reflection.Emit.TypeBuilder.CreateTypeInfo()
       at StreamJsonRpc.ProxyGeneration.CreateParameterObjectType(ModuleBuilder moduleBuilder, ParameterInfo[] parameters)
       at StreamJsonRpc.ProxyGeneration.Get(TypeInfo serviceInterface)
       at StreamJsonRpc.JsonRpc.Attach[T](JsonRpcProxyOptions options)
       at Microsoft.ServiceHub.Framework.ServiceJsonRpcDescriptor.JsonRpcConnection.ConstructRpcClient[T]()
--- End of inner exception stack trace ---
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Microsoft.ServiceHub.Framework.ServiceRpcDescriptor.RpcConnection.ConstructRpcClient(Type interfaceType)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions