Problem Listing All Servers C#


I’ve decided to utilize the Graal Reborn libraries to try to create my own RemoteControl (just to play around). I’m attempting to just simply list the available servers with a foreach() loop, but I have some problems with that–

The error that appears is ‘Object reference not set to an instance of an object’. I realize that somewhere, an object needs to be initialized, but I do not know how I can fix this error.


I suggest learning how to use C# before writing your own RC and such, regardless of how much Cadavre’s libraries hold your hand through the process.

The code you provided is too ambiguous for anybody to tell what you’re doing wrong, but at a guess I’d say you don’t have any servers instatciated:

foreach (TServer server in LSConn.serverList) { Console.WriteLine(server.getName()); }

Your compiler/debugger should provide you with the exact line number and class in which the error is occurring, without that, or the rest of your relevant source I’d have better luck finding your error by pissing into the wind

The only code I wrote is the code I provided, which appears to be the only required code to do a simple task like listing the server (I looked through ServerWindow.cs in Cadavre’s RC).

I forgot to mention the error line yesterday as it was late at night. The error occurs on the foreach loop line. LSConn.serverList appears not to be initialized. The variable is null.

Sorry, you’re right about me not knowing too much C#. I have just recently made the transition to C# from Java. They’re very similar, so I’ll have no problem picking it up.

Can you create a good object without the loop?