Jump to content
TrinityCore
Sign in to follow this  
Eternalis

How to launch the trinitycore server from a c# app ?

Recommended Posts

Hello.

I'm working on some kind of admin app in c# to allow my crew and myself to start/stop the servers and update files in the core folder remotely, but i can't figure out how to start the server.

When i'm trying to do so, I can see something launching in my taskbar but it immediately close and the log for the server file does not update.

On the C# side the process code tell me that the process started successfully and it is working with other softwares so i guess it does not come from there.

I suppose it is the server that is closing immediately. Is there something specific to know when starting the server from another app ?

Here is the c# code if it can help to find the problem :

           if(p_command.Equals("StartServer"))
            {
                LogMessage("Starting server...");
                Send(handler, "ServerStarting");
                try
                {
                    using (Process myProcess = new Process())
                    {
                        myProcess.StartInfo.UseShellExecute = false;
                        myProcess.StartInfo.FileName = ConfigurationManager.AppSettings["corePath"] + "/authserver.exe";

                        myProcess.StartInfo.WorkingDirectory = ConfigurationManager.AppSettings["corePath"]; //This line solved the problem
                        myProcess.Start();
                    }
                }
                catch (Exception e)
                {
                    LogMessage(e.Message);
                }
            }

 

Edit : I found the solution.

By starting the process from my c# app, it wasn't setting the working directory of the server automatically which caused it to not find the dll, ...

The solution to this problem is the line pointed above.

Have a nice day !

Edited by Eternalis
Update with the solution

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...