• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

C# TrinityCore executable

Neccta

Exalted Member
I've hit a wall in the program I'm creating, it launches the authserver.exe with "Process.Start();" however it can't find the config file, but running it manually it works fine. Any suggestions?
 

Tommy

Founder
I just made a test program and it works fine for me. Can you paste the code? It'll help since we need to see it just in case you wrote something wrong. Also, did you make sure you removed the '.dist' extension from the authserver config?
 

Neccta

Exalted Member
Sorry I should have also said that I'm redirecting the IO stream to a rich text box.
Code:
            Process world = new Process();
            string w = Properties.Settings.Default.worldsrv;
            world.StartInfo.FileName = w;
            world.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            world.StartInfo.CreateNoWindow = false;
            world.StartInfo.UseShellExecute = false;
            world.StartInfo.RedirectStandardOutput = true;
            world.Start();

            StreamReader sr = world.StandardOutput;
            string worldOutput = sr.ReadLine();
            richTextBox1.AppendText(worldOutput + Environment.NewLine);

Launching the program works, just not entirely, I get back "Error in config file: cannot open file (authserver.conf)"
 
Last edited:

yvoms

Exalted Member
doesn't seem to look its the config file, as manually running does the job,
did you recheck for grammar/spelling, thats most likely the problem here.

Did you make sure you put it in the same location as the authserver and its config file?
Can you try running it as administrator and postback results?
 
Last edited:

Tommy

Founder
Sorry I should have also said that I'm redirecting the IO stream to a rich text box.
Code:
            Process world = new Process();
            string w = Properties.Settings.Default.worldsrv;
            world.StartInfo.FileName = w;
            world.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            world.StartInfo.CreateNoWindow = false;
            world.StartInfo.UseShellExecute = false;
            world.StartInfo.RedirectStandardOutput = true;
            world.Start();

            StreamReader sr = world.StandardOutput;
            string worldOutput = sr.ReadLine();
            richTextBox1.AppendText(worldOutput + Environment.NewLine);

Launching the program works, just not entirely, I get back "Error in config file: cannot open file (authserver.conf)"

The code works for me. There's no error or anything. Make sure, as I mentioned above, the .dist extension is removed from "authserver.conf.dist". Otherwise, I have no clue.
 

Neccta

Exalted Member
Well I am using a repack to test. Did you compile TrinityCore yourself? I'll try another repack and if that doesn't work I'll just compile it myself.
Oh and yeah, there is no dist ;)

EDIT: Tried running it in administrator mode, didn't work.
 
Last edited:

Tommy

Founder
Well I am using a repack to test. Did you compile TrinityCore yourself? I'll try another repack and if that doesn't work I'll just compile it myself.
Oh and yeah, there is no dist ;)

EDIT: Tried running it in administrator mode, didn't work.

Yes, my TC source was compiled. Unless the repack sources have been edited, I'd suggest compiling the source yourself. But, doubt that's the case here. Can you show me the path you're using to start the program? Also, I used a Console Application and pasted your code in it, edited the path to "authserver.exe", put the exe where the authserver is and started it.
 

Tommy

Founder
Tested your code thoroughly. Found out if you put your program where authserver.exe/worldserver.exe is, it will launch without any errors.

Found out that:

https://github.com/Neccta/TrinityCore-GUI/blob/master/Form1.cs#L81

Needs to be changed to "authsrv" since it is auth. Copy & paste? :p


Not sure what you're trying to do here: https://github.com/Neccta/TrinityCore-GUI/blob/master/Form3.cs#L64. The program is already running, change it to "new Form1().Show();" (which is kinda bad practice if you're needing to edit that form through a variable. Though, for testing it is fine).


As for an alternate way in launching the executables without your program being in the same directory, perhaps you need to add some command arguments or something similar so it can find the config(s).
 

Neccta

Exalted Member
Not sure what you're trying to do here: https://github.com/Neccta/TrinityCor...r/Form3.cs#L64. The program is already running, change it to "new Form1().Show();".

Oh that's because form3 should start the first time you use the program, then the bool is set to false so it doesn't show up again. But once you hit the OK button form3 would disappear, that's why I check for firstrun = true then run form 1. Oh and nice catch with the copy and paste haha.

I also tried adding world.StartInfo.Arguments = "-c worldserver.conf"; didn't seem to work. I wonder if it doesn't work just because it's in debug mode? I don't know, but it's good to hear that it'll work if it's in the same directory.
 
Last edited:

Tommy

Founder
Oh that's because form3 should start the first time you use the program, then the bool is set to false so it doesn't show up again. But once you hit the OK button form3 would disappear, that's why I check for firstrun = true then run form 1. Oh and nice catch with the copy and paste haha.

I also tried adding world.StartInfo.Arguments = "-c worldserver.conf"; didn't seem to work. I wonder if it doesn't work just because it's in debug mode? I don't know, but it's good to hear that it'll work if it's in the same directory.

That's already handled in Program.cs (new Form3): https://github.com/Neccta/TrinityCore-GUI/blob/master/Program.cs#L22

Running it again caused thread related errors because of your "Application.Run" code in a button event on an existing form that is already running. You should also remove the check "first run" and remove Application.Run(new Form3()) in Program.cs and make a new "Form1_Load" event and add "FirstRun = false" & showing Form3 in there.
 

Neccta

Exalted Member
I'll have to try that and see if it works. I kinda gave up on trying to get the console output to show up in my program. I believe it's because it doesn't output on "StandardOutput". I could also read the log files using "FileSystemWatcher"and display the output in my program which would be a lot easier.
 
Top