NetworkServer in Console Application

Hi!

I need a console / windows service application for hosting the network communication and a mysql database for my current project. The current network stack is created with Lidgren Network, but I try to switch to new Unity Networking.
It’s possible to create a console application with the NetworkServer?

I try the following:

  1. Create new Console Application
  2. Link UnityEngine and UnityEngine.Networking to the references
  3. Start the Server with: NetworkServer.Listen(4444);

But if I start the Console App I get the following Exception:
“An unhandled exception of type ‘System.Security.SecurityException’ occurred in UnityEngine.Networking.dll
Additional information: ECall methods must be packaged into a system module.
at UnityEngine.Networking.NetworkTransport.Init()
at UnityEngine.Networking.NetworkServer…ctor()
at UnityEngine.Networking.NetworkServer.get_instance()
at UnityEngine.Networking.NetworkServer.Listen(Int32 serverPort)
at Server.Program.Main(String[ ] args) in D:\dev\Tests\DedicatedServerTest\Server\Program.cs:line 13
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[ ] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()”

There are plans to allow creating own seperate Server for Unity Networking?

Thanks!

The Unity transport layer currently cannot be used outside of the Unity Engine. There are plans for a separate independent UNet DLL with a C# API in a future release for applications like this.

2 Likes

I just found this out too… what a waste of 5 hours. Seriously, you really expect a client / server networking tests to be done inside of a graphical IDE?

Lame… T_T
This needs to be done, especially since this thread was started months ago now…