Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

[VS2012] NullReferenceException when using args (command line application in c#)

$
0
0

Why is it that following code gives me a NullReferenceException when I run the application, a commandline c# application, with arguments? The arguments are valid and args[0] contains the text I'm trying to pass. Also, that Main's class is set as startup object. Peer.Room is also a string. Length is 1.

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Peer.Room = args[0];
            }
        }

The strangest thing of all is that it worked some days ago and I changed not a single bit.
It suddenly stopped working.

Could someone nice help me please to find a way to fix this?
I really don't want to recompile my application 23 times just so I have a different version for every room...


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>