I'm playing around with XSockets.NET, and I've spent way too much time debugging what should be a simple problem. I'm using the standard templates that come with XSockets, which create a project called XSockets.DevServer, and a class within that project called DebugInstance. When I host this DebugInstance class within my web project, all seems to work as expected. However, when I try to host it within the XSockets.Debug.Console project, or when I try to get it to run on my production IIS instance, I get a NullReferenceException in the code below:
[ImportOne(typeof(IXBaseServerContainer))]
public IXBaseServerContainer wss { get; set; }
public DebugInstance()
{
try
{
Debug.AutoFlush = true;
this.ComposeMe();
// NullReferenceException on the next line - wss apparently never gets set.
wss.OnServersStarted += wss_OnServersStarted;
wss.OnServerClientConnection += wss_OnServerClientConnection;
wss.OnServerClientDisconnection += wss_OnServerClientDisconnection;
wss.OnError += wss_OnError;
wss.OnIncommingTextData += wss_OnIncommingTextData;
wss.OnOutgoingText += wss_OnOutgoingText;
wss.OnServersStopped += wss_OnServersStopped;
wss.StartServers();
}
catch (Exception ex)
{
Debug.WriteLine("Exception while starting server: " + ex);
Debug.WriteLine("Press enter to quit");
}
}
Clearly the problem is happening within this.ComposeMe()
, but there's no troubleshooting information, and since XSockets isn't apparently open-sourced, I haven't been able to step through the code to figure out where the problem is.
EDIT: To be clear, I know what a NullReferenceException is. In this case its immediate cause is the fact that wss
is null. What I want to know is its proximate cause, i.e., why ComposeMe()
doesn’t assign it, even though that's what it's apparently supposed to be doing. Apparently the homegrown IOC that XSockets is using to support its plugin architecture is supposed to find an instance of IXBaseServerContainer
, but it's apparently not - and I have no idea why. And not having the source, I'm not even sure what the candidates for IXBaseServerContainer
are.
EDIT 2012-11-06: Here's what the appSettings element of my app.config looks like:
<appSettings>
<add key="XSocketServerStartport" value="4502"/>
<add key="UsePolicyServer" value="true"/>
<add key="XSockets.PluginCatalog" value="XSockets\XSocketServerPlugins\"/>
<add key="XSockets.PluginFilter" value="*.dll"/>
<add key="XMessageInterceptorsEnabled" value="false"/>
<add key="XErrorInterceptorsEnabled" value="false"/>
<add key="XConnectionInterceptorsEnabled" value="false"/>
<add key="XHandshakeInterceptorsEnabled" value="false"/>
<add key="XSocketLogPath" value="XSockets\XSocketServerPlugins\Log"/>
<add key="XBufferSize" value="8192"/>
</appSettings>
I've got all the files mentioned below in both my $(ProjectDir)\XSockets\XSocketServerPlugins\
and my $(TargetDir)\XSockets\XSocketServerPlugins\
folders, e.g.:
10/29/2012 09:53 AM 15,872 XSockets.Core.Communication.dll
10/29/2012 09:53 AM 70,656 XSockets.Core.dll
10/29/2012 09:53 AM 8,192 XSockets.DevelopmentServer.dll
10/29/2012 09:53 AM 11,776 XSockets.Extensibility.Handlers.dll
10/29/2012 09:53 AM 10,240 XSockets.Extensibility.Interceptors.dll
10/29/2012 09:53 AM 23,040 XSockets.External.dll
10/29/2012 09:53 AM 24,064 XSockets.Protocol.dll
10/29/2012 09:53 AM 39,424 XSockets.Server.dll
11/05/2012 05:37 PM 12,288 XSockets.WebRTC.Prototype.Shared.Handlers.dll
Any thoughts?