0

I am working on a self-sustaining web application by embedding servers into it. One of the servers is a WebSocket server powered by XSockets.

If I xbuild the solution and then mono Application.exe - works as expected.

If I then mkbundle --deps -o nancy-xsockets.so Application.exe ... (notice the -o being in the same directory, the ... in reality are paths to required assemblies) and run with ./nancy-xsockets.so it works as expected.

Then, if I mkbundle --deps -o MKBUNDLE/nancy-xsockets.so Application.exe ... (notice the -o NOT BEING in the same directory), and run with MKBUNDLE/nancy-xsockets.so - it works as expected.

Now, if I cd MKBUNDLE and then ./nancy-xsockets.so I am welcomed by this error:

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for XSockets.Plugin.Framework.Composable ---> System.IO.DirectoryNotFoundException: Directory '/usr/lib/mono/gac/XSockets.Plugin.Framework/1.4.3.0__e0d515f22052a108' not found.
  at System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) [0x00000] in <filename unknown>:0
  at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0
  at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0
  at System.IO.Directory.GetFiles (System.String path, System.String searchPattern, SearchOption searchOption) [0x00000] in <filename unknown>:0
  at XSockets.Plugin.Framework.Composable+<>c__DisplayClass9.<AddLocation>b__8 (System.String fi) [0x00000] in <filename unknown>:0
  at System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator12`2[System.String,System.String].MoveNext () [0x00000] in <filename unknown>:0
  at XSockets.Plugin.Framework.Composable.AddLocation (System.String assemblyLocation, SearchOption searchOption, Boolean ignoreException) [0x00000] in <filename unknown>:0
  at XSockets.Plugin.Framework.Composable.SetPluginCatalog () [0x00000] in <filename unknown>:0
  at XSockets.Plugin.Framework.Composable..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Core.Bootstrap.XSocket (Int32 port) [0x00000] in <filename unknown>:0
  at Core.Bootstrap.Start (Int32 nancyPort, Int32 xSocketPort) [0x00000] in <filename unknown>:0
  at Core.Startup.Main (System.String[] args) [0x00000] in <filename unknown>:0

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at Core.Bootstrap.Dispose () [0x00000] in <filename unknown>:0
  at Core.Startup.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at Core.Bootstrap.Dispose () [0x00000] in <filename unknown>:0
  at Core.Startup.Main (System.String[] args) [0x00000] in <filename unknown>:0

It seems to happen when the working directory has none of the .dll's around.

It feels as if the XSockets cannot find configuration and is falling back to a default value.

How do I fix this issue?

Update:

It's worth noting, that with mkbundle, I really instruct it to pack everything together. I end up with a single executable "nancy-xsockets.so", when I run it, it errors out with the above message. Assuming that Uffe's answer might help, the obvious choice would be to add executables root path to Composable, but in my case Composable.AddLocation didn't seem to help - same error.

I looked forward to see where the problem may reside, since, if the *.dll assemblies are with the single executable in one directory, it seems to work (probably loads them instead of looking inside the bundled assembly). I started to remove the *.dll files one by another until I stumbled on that it's exactly XSockets.Plugin.Framework.dll.

So, if I have these contents:

[root@web-apps Release]# ls
modules  nancy-xsockets.so

The subsequent call to:

[root@web-apps Release]# ./nancy-xsockets.so

Will end up with the error as seen above.

But, if I have:

[root@web-apps Release]# ls
modules  nancy-xsockets.so  XSockets.Plugin.Framework.dll

The following calls runs flawlessly:

[root@web-apps Release]# ./nancy-xsockets.so
Looking for modules in: /root/stoneos-nancy-xsockets/Release/modules
Starting Nancy on: 1337, XSockets on: 1338
Adding path /root/stoneos-nancy-xsockets/Release to XSockets Composable
XSockets and Nancy started.
Press any key to exit.

This seems to be a problem in XSockets, more specifically, the XSockets.Plugin.Framework.Composable. It's static constructor appears to be calling SetPluginCatalog, which then is calling AddLocation and probably fails on this step when mkbundled.

Is there any way to disable this "default" location?

Community
  • 1
  • 1
tomsseisums
  • 13,168
  • 19
  • 83
  • 145

1 Answers1

0

I have no experience in Nancy but I do know that if the working directory does not have the assemblies you have to tell the plugin framework where to look before you start using it.

For example, the line below would add the location "c:\temp\test" so that the framework would look there for assemblies.

Composable.AddLocation("c:\\temp\\test");

This should be done before you start the server. If you do it post start you will have to add another line

Composable.AddLocation("c:\\temp\\test");
Composable.ReCompose();
Uffe
  • 2,275
  • 1
  • 13
  • 9