Question

I am working on a Unity project where I need to work with a remoting client. I have created an interface class and I am using a remoting server in an other Unity project.

While the server is working without problems, the creation of the client fails with following exception:

System.TypeInitializationException: An exception was thrown by the type initializer for System.Runtime.Remoting.Channels.SocketCache ---> System.NotImplementedException: The requested feature is not implemented. at System.Threading.ThreadPool.UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, System.Object state, TimeSpan timeout, Boolean executeOnlyOnce) [0x00000] in :0

My code for the client:

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());
    }
....

Does anyone know how to solve this problem? According to Mono FAQ, Mono should have remoting support. I am workin with Unity 3.5.1 (should have Mono 2.6.3) on a Windows 7 x64 Professional machine.

Thanks in advance

Was it helpful?

Solution

I am using Unity to do the exact same thing.

First thing you have to do is change the player Api Compatibility Level from ".Net 2.0 subset" to ".Net 2.0"

Next you have to get the 2.0 mono library "System.Runtime.Remoting.dll" from MonoDevelop

Mine was located at "/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Libraries/mono/2.0/System.Runtime.Remoting.dll"

place that into the "Assets/Plugins" folder and Unity will take care of dragging out the rest of the libraries.

From then on out, it seems that remoting works without a hitch :)

If you add the Remoting dll and build only to find an error like "But the dll is not allowed to be included or could not be found" then your still using ".Net 2.0 Subset"

OTHER TIPS

There are two options here:

  1. The used .NET subset does not support it. Switch between the 2.0 subset and full 2.0 in the player settings and test again
  2. If that does not help then I fear you can not do anything about it aside of either implementing an own protocol or going true native code using DLLImport. The problem here is the unsafe code reliance which in Unity normally is disabled and cut from its custom Mono version (which bases on Mono 2.6). Unity does neither support nor use the systems Mono version, so any tests and assumptions basing on those are irrelevant in this situation.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top