class Program
{
interface IDeviceInvoker
{
public byte[] GetDeviceName();
public byte[] GetDeviceProto();
}
static void Main(string[] args)
{
var client = new Client("tcp://127.0.0.1");
var log = new Log();
client.Use(log.IOHandler).Use(log.InvokeHandler);
var proxy = client.UseService<IDeviceInvoker>();
var deviceName = proxy.GetDeviceName();
// var invoke = client.Invoke<byte[]>("GetDeviceName", null);
// Console.WriteLine(System.Text.Encoding.UTF8.GetString(invoke));
}
}
被注释的代码,调用正常,但是没被注释的调用失败,报错
Unhandled exception. System.TypeLoadException: Type '$Proxy0' from assembly '$Assembly0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface
.
at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
at System.Reflection.Emit.TypeBuilder.CreateTypeInfo()
at Hprose.RPC.Proxy.GetProxyWithoutCache(Type[] interfaces)
at Hprose.RPC.Proxy.<>c.<GetProxy>b__30_0(ProxyKey proxykey)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Hprose.RPC.Proxy.GetProxy(Type[] interfaces)
at Hprose.RPC.Proxy.NewInstance(Type[] interfaces, IInvocationHandler handler)
at Hprose.RPC.Client.UseService[T](String ns)
at hproseClient.Program.Main(String[] args) in F:\go\hproseTest\client\hproseClient\hproseClient\Program.cs:line 21
Golang服务端代码如下
疑问如下
dotnet客户端,如果服务端实例方法,那么客户端使用一个自定接口 能否实现对应的转换,我的dotnet客户端代码如下
被注释的代码,调用正常,但是没被注释的调用失败,报错