我正在开发一个需要与远程客户端合作的 Unity 项目。我创建了一个接口类,并且在另一个 Unity 项目中使用了远程服务器。
当服务器正常工作时,客户端的创建失败并出现以下异常:
System.TypeInitializationException:System.Runtime.Remoting.Channels.SocketCache 的类型初始化程序引发了异常---> System.NotImplementedException:请求的功能未实现。在 System.Threading.ThreadPool.UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject,System.Threading.WaitOrTimerCallback 回调,System.Object 状态,TimeSpan 超时,布尔 executeOnlyOnce)[0x00000] 在:0
我的客户代码:
MyRemotableObject remoteObject;
void Awake ()
{
try
{
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan, false);
remoteObject = (MyRemotableObject)Activator.GetObject(typeof(MyRemotableObject), "tcp://localhost:124/TargetShooterMenu");
}
catch (Exception e)
{
Debug.LogError(e.ToString());
}
....
有谁知道如何解决这个问题?根据Mono FAQ,Mono 应该有远程支持。我在 Windows 7 x64 Professional 机器上使用 Unity 3.5.1(应该有 Mono 2.6.3)。
提前致谢