Home > Software engineering >  How do I call my StartServer function correctly?
How do I call my StartServer function correctly?

Time:01-02

I have a server which i can run perfectly fine standalone on my windows machine, but i'd like to incorporate that same exact code into a UWP app. I've tried putting the entire Server.cs inside of my app, making the main method a public static void StartServer(string[] args). I then have a button which calls the Button_Click() event.

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Hi!");
            Analytics.TrackEvent("Hi!");
            Server.StartServer();
            
        }

This does not work. I'm getting the error " There is no given argument given that corresponds to the required formal parameter 'args' of Server.StartServer(string[]) " How do I fix this?

CodePudding user response:

It seems your StartServer function takes a string array as an argument. I don't exactly know which strings to put inside of this array but you could try to put an Empty string array like

Server.StartServer(new string[] {});
  • Related