Issues starting up server with Ninject

Options
Matthewsre
edited November 2013 in Photon Server
I am having the same issue as the person in this thread:
http://forum.exitgames.com/viewtopic.php?f=5&t=1067&p=5035&hilit=ninject#p5035

Here is the exception in my log:

2013-11-02 01:56:26,098 [1] INFO PhotonServer.Mmo.Photon.Application.PhotonApplication [(null)] - Initializing kernel...
2013-11-02 01:56:26,160 [1] ERROR Photon.SocketServer.ApplicationBase [(null)] - System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\GameDev\Photon\deploy\Shared'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption, Boolean checkHost)
at System.IO.Directory.InternalGetFiles(String path, String searchPattern, SearchOption searchOption)
at Ninject.Modules.ModuleLoader.<>c__DisplayClass8.<GetFilesMatchingPattern>b__7(String path) in c:\Projects\Ninject\ninject\src\Ninject\Modules\ModuleLoader.cs:line 67
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.GroupedEnumerable`3.GetEnumerator()
at Ninject.Modules.ModuleLoader.LoadModules(IEnumerable`1 patterns) in c:\Projects\Ninject\ninject\src\Ninject\Modules\ModuleLoader.cs:line 54
at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 100
at PhotonServer.Mmo.Photon.Application.PhotonApplication.Setup() in c:\GameDev\PhotonServer\PhotonServer.Mmo.Photon\Application\PhotonApplication.cs:line 56
at Photon.SocketServer.ApplicationBase.PhotonHostRuntimeInterfaces.IPhotonControl.OnPhotonRunning() in c:\svncontent\photon-socketserver-sdk_3.2\src\Photon.SocketServer\ApplicationBase.cs:line 1065
2013-11-02 01:56:26,190 [1] ERROR Photon.SocketServer.ApplicationBase [(null)] - System.NullReferenceException: Object reference not set to an instance of an object.
at PhotonServer.Mmo.Photon.Application.PhotonApplication.OnStopRequested() in c:\GameDev\PhotonServer\PhotonServer.Mmo.Photon\Application\PhotonApplication.cs:line 134
at Photon.SocketServer.ApplicationBase.PhotonHostRuntimeInterfaces.IPhotonControl.OnStopRequested() in c:\svncontent\photon-socketserver-sdk_3.2\src\Photon.SocketServer\ApplicationBase.cs:line 1124



When I create the shared folder my application hangs when getting a standard kernel:

[code2=csharp]var kernel = new StandardKernel();[/code2]

Here is the log I get, with no exceptions and unable to stop/start the service:

24128: 02:00:51.340 - Will accept ANY sub-protocols from the client
24128: 02:00:51.340 - No automatic WebSocket ping
24128: 02:00:51.370 - Service is running...
12932: 02:00:52.939 - CManagedHost::OnDefaultAction() - OPR_AppDomainUnload - eUnloadAppDomain
12932: 02:00:52.947 - CManagedHost::OnDomainUnload() - 6
12932: 02:00:52.947 - Releasing reference on default app domain


Any help would be greatly appreciated, has anyone successfully got Photon server up and running with Ninject?

Comments

  • Sorry, we can not provide support for any 3rd party libraries here. :(

    We had a discussion about NInject & SecurityExceptions here, maybe that helps: viewtopic.php?f=5&t=2796&p=12936&hilit=ninject#p12936
  • I found that one and it was an unrelated issue, I did however fix my issue by disabling Loading of extensions in Ninject in case anyone else runs into this issue.

    By the way thank you for this excellent product with the "free up to" option, I really like this model :)
  • Thanks! And also thanks for coming back and sharing your solution, it might help somebody else as well :-)
  • Hi guys!

    The same workaround was for me. Sorry that didn't post it. This problem is occurring because the Ninject is using a AppDomain.RelativeSearchPath property when trying to find and load extensions. The value of this property in PhotonServer runtime is "APPLICATION_FOLDER\bin;bin_Win64;Shared;" that looks strange for me. Anyway Ninject combines the AppDomain.BaseDirectory and the AppDomain.RelativeSearchPath to find the extensions and as a result DirectoryNotFoundException is thrown. See https://github.com/ninject/ninject/blob ... eLoader.cs method GetBaseDirectories(). The version of my PhotonHostRuntime.dll is 3.0.26.

    Thanks!