Launching C# program from another C# program2019 Community Moderator ElectionHow do I calculate someone's age in C#?What is the difference between String and string in C#?Cast int to enum in C#How do I enumerate an enum in C#?How to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?What are the correct version numbers for C#?Why is Dictionary preferred over Hashtable in C#?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I update the GUI from another thread?Get int value from enum in C#

Why are special aircraft used for the carriers in the United States Navy?

If there are any 3nion, 5nion, 7nion, 9nion, 10nion, etc.

How to disable or uninstall iTunes under High Sierra without disabling SIP

How to mitigate "bandwagon attacking" from players?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Levi-Civita symbol: 3D matrix

It doesn't matter the side you see it

What is better: yes / no radio, or simple checkbox?

Deal the cards to the players

Is divide-by-zero a security vulnerability?

3.5% Interest Student Loan or use all of my savings on Tuition?

Meaning of word ягоза

Difference between 'stomach' and 'uterus'

Can the Shape Water Cantrip be used to manipulate blood?

Transparent Materials for Creating Martian Dome Ceilings

School performs periodic password audits. Is my password compromised?

How to kill a localhost:8080

What can I do if someone tampers with my SSH public key?

The need of reserving one's ability in job interviews

How to get the first element while continue streaming?

A bug in Excel? Conditional formatting for marking duplicates also highlights unique value

Why do phishing e-mails use faked e-mail addresses instead of the real one?

Quitting employee has privileged access to critical information

PTIJ: Aharon, King of Egypt



Launching C# program from another C# program



2019 Community Moderator ElectionHow do I calculate someone's age in C#?What is the difference between String and string in C#?Cast int to enum in C#How do I enumerate an enum in C#?How to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?What are the correct version numbers for C#?Why is Dictionary preferred over Hashtable in C#?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I update the GUI from another thread?Get int value from enum in C#










2















Due to me having knowledge of launching apps I am aware that you have multiple ways of launching an application in C# .NET, but I'm running into a issue that occurs when attempting to launch a SDL2 application.



I have attempted the following using the Process class to:



  • Start the .exe file of the build.

  • Start the application using "cmd.exe /K" or "cmd.exe /c" followed by "exec" or "call" or "start" followed by "path to file" or "path to batch file to launch the application". Launching the application via a batch file and CMD works fine. But, whenever I attempt to even launch the application (even in a new instance of Command-Prompt launched from cmd.exe /? start cmd.exe ?params) it will yield no result.

What I can observe is that the application tries to open. It takes forever to launch into the Window mode (starting the 3D environment). After a timeout it will either, render a couple of frames of a blank window before closing or close immediately after opening the window.



So my question is, does anyone have succesfully made a launcher application for a SDL app written in C# .NET? Or knows a way to debug this behaviour? Because unfortunately, the app does not send out a error message and since SDL safely closes the application I can't observe a crash either.



Edit #1



I'm not doing anything fancy with parameters as there shouldn't be any. I already have another one functioning that launches a normal C# application as my launcher requires to open 2 programs. 1 SLD application, 1 COM:VBA controlling application.
Given:



string audioSpectrumProgram = "AudioSpectrum.exe";
string audioSpectrumBatchProgram = "AudioSpectrum.bat";

private void BtnLaunchPPTApp_OnClick()

//Powerpoint controlling application
pVBAApp = Process.Start(presenterProgram, $""this.path" this.audioFormatParams[0] ((this.ckboxGenerate.Checked) ? "--create" : "") lang=this.languageCodesParams[this.cboxLanguage.SelectedIndex]");



Method 1:



private void BtnLaunchSDLApp_OnClick()

pVizualizer = Process.Start(audioSpectrumProgram); //file launched from local path (is correct)



Method 2:



pVizualizer = Process.Start(audioSpectrumBatchProgram); //file launched from local path (is correct)


Method 3:



ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
FileInfo spectrumFileInfo = new FileInfo(audioSpectrumProgram);
if (spectrumFileInfo.Exists)
info.Arguments = $"/c "spectrumFileInfo.FullName"";
pVizualizer = Process.Start(info);


Method 4:
based on senario of method 3. You don't have to parse arguments using ProcessStartInfo.



pVizualizer = Process.Start($"cmd.exe /K call "spectrumFileInfo.FullName"") //to observe what happens to the application


Edit #2



Not affected by changing the UseShellExecute to true or false



private void btnOpenVisualizer_Click(object sender, EventArgs e)

FileInfo spectrumFileInfo = new FileInfo(audioSpectrumProgram);
ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
info.UseShellExecute = true;
pVizualizer = new Process();
pVizualizer.StartInfo = info;
pVizualizer.EnableRaisingEvents = true;
pVizualizer.Exited += new EventHandler(myProcess_Exited);
pVizualizer.Start();


private void myProcess_Exited(object sender, System.EventArgs e)

Console.WriteLine(
$"Exit time : pVizualizer.ExitTimen" +
$"Exit code : pVizualizer.ExitCoden"
);










share|improve this question









New contributor




Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Hi @Ryan and welcome to StackOverflow. I think there might be something wrong with the code which is used for launching the process. Could you please share that code to allow us to help you?

    – Just Shadow
    17 hours ago











  • Please add code you are using and not working. I suspect you passing parameters incorrectly.

    – Reniuz
    17 hours ago












  • It should technically be as simple as just launching the app as it does not utilise any params except for launching an Exec or Batch file from CMD instead of launching the process directly.

    – Ryan van den Bogaard
    17 hours ago











  • Oh yeah would like to emphasize that the application does in fact start. It's just that the SDL application that runs fine on its own and launched from a batch file or command prompt. It simply refuses to open a 3D environment when launched from another C# application, even if the LAUNCHER application is executing a call to start the process from an newly made CMD instance in C#. And no it can run side by side other C# applications if you'd think that this is the issue.

    – Ryan van den Bogaard
    16 hours ago












  • Have you tried to set UseShellExecute to false?

    – Reniuz
    16 hours ago















2















Due to me having knowledge of launching apps I am aware that you have multiple ways of launching an application in C# .NET, but I'm running into a issue that occurs when attempting to launch a SDL2 application.



I have attempted the following using the Process class to:



  • Start the .exe file of the build.

  • Start the application using "cmd.exe /K" or "cmd.exe /c" followed by "exec" or "call" or "start" followed by "path to file" or "path to batch file to launch the application". Launching the application via a batch file and CMD works fine. But, whenever I attempt to even launch the application (even in a new instance of Command-Prompt launched from cmd.exe /? start cmd.exe ?params) it will yield no result.

What I can observe is that the application tries to open. It takes forever to launch into the Window mode (starting the 3D environment). After a timeout it will either, render a couple of frames of a blank window before closing or close immediately after opening the window.



So my question is, does anyone have succesfully made a launcher application for a SDL app written in C# .NET? Or knows a way to debug this behaviour? Because unfortunately, the app does not send out a error message and since SDL safely closes the application I can't observe a crash either.



Edit #1



I'm not doing anything fancy with parameters as there shouldn't be any. I already have another one functioning that launches a normal C# application as my launcher requires to open 2 programs. 1 SLD application, 1 COM:VBA controlling application.
Given:



string audioSpectrumProgram = "AudioSpectrum.exe";
string audioSpectrumBatchProgram = "AudioSpectrum.bat";

private void BtnLaunchPPTApp_OnClick()

//Powerpoint controlling application
pVBAApp = Process.Start(presenterProgram, $""this.path" this.audioFormatParams[0] ((this.ckboxGenerate.Checked) ? "--create" : "") lang=this.languageCodesParams[this.cboxLanguage.SelectedIndex]");



Method 1:



private void BtnLaunchSDLApp_OnClick()

pVizualizer = Process.Start(audioSpectrumProgram); //file launched from local path (is correct)



Method 2:



pVizualizer = Process.Start(audioSpectrumBatchProgram); //file launched from local path (is correct)


Method 3:



ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
FileInfo spectrumFileInfo = new FileInfo(audioSpectrumProgram);
if (spectrumFileInfo.Exists)
info.Arguments = $"/c "spectrumFileInfo.FullName"";
pVizualizer = Process.Start(info);


Method 4:
based on senario of method 3. You don't have to parse arguments using ProcessStartInfo.



pVizualizer = Process.Start($"cmd.exe /K call "spectrumFileInfo.FullName"") //to observe what happens to the application


Edit #2



Not affected by changing the UseShellExecute to true or false



private void btnOpenVisualizer_Click(object sender, EventArgs e)

FileInfo spectrumFileInfo = new FileInfo(audioSpectrumProgram);
ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
info.UseShellExecute = true;
pVizualizer = new Process();
pVizualizer.StartInfo = info;
pVizualizer.EnableRaisingEvents = true;
pVizualizer.Exited += new EventHandler(myProcess_Exited);
pVizualizer.Start();


private void myProcess_Exited(object sender, System.EventArgs e)

Console.WriteLine(
$"Exit time : pVizualizer.ExitTimen" +
$"Exit code : pVizualizer.ExitCoden"
);










share|improve this question









New contributor




Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Hi @Ryan and welcome to StackOverflow. I think there might be something wrong with the code which is used for launching the process. Could you please share that code to allow us to help you?

    – Just Shadow
    17 hours ago











  • Please add code you are using and not working. I suspect you passing parameters incorrectly.

    – Reniuz
    17 hours ago












  • It should technically be as simple as just launching the app as it does not utilise any params except for launching an Exec or Batch file from CMD instead of launching the process directly.

    – Ryan van den Bogaard
    17 hours ago











  • Oh yeah would like to emphasize that the application does in fact start. It's just that the SDL application that runs fine on its own and launched from a batch file or command prompt. It simply refuses to open a 3D environment when launched from another C# application, even if the LAUNCHER application is executing a call to start the process from an newly made CMD instance in C#. And no it can run side by side other C# applications if you'd think that this is the issue.

    – Ryan van den Bogaard
    16 hours ago












  • Have you tried to set UseShellExecute to false?

    – Reniuz
    16 hours ago













2












2








2








Due to me having knowledge of launching apps I am aware that you have multiple ways of launching an application in C# .NET, but I'm running into a issue that occurs when attempting to launch a SDL2 application.



I have attempted the following using the Process class to:



  • Start the .exe file of the build.

  • Start the application using "cmd.exe /K" or "cmd.exe /c" followed by "exec" or "call" or "start" followed by "path to file" or "path to batch file to launch the application". Launching the application via a batch file and CMD works fine. But, whenever I attempt to even launch the application (even in a new instance of Command-Prompt launched from cmd.exe /? start cmd.exe ?params) it will yield no result.

What I can observe is that the application tries to open. It takes forever to launch into the Window mode (starting the 3D environment). After a timeout it will either, render a couple of frames of a blank window before closing or close immediately after opening the window.



So my question is, does anyone have succesfully made a launcher application for a SDL app written in C# .NET? Or knows a way to debug this behaviour? Because unfortunately, the app does not send out a error message and since SDL safely closes the application I can't observe a crash either.



Edit #1



I'm not doing anything fancy with parameters as there shouldn't be any. I already have another one functioning that launches a normal C# application as my launcher requires to open 2 programs. 1 SLD application, 1 COM:VBA controlling application.
Given:



string audioSpectrumProgram = "AudioSpectrum.exe";
string audioSpectrumBatchProgram = "AudioSpectrum.bat";

private void BtnLaunchPPTApp_OnClick()

//Powerpoint controlling application
pVBAApp = Process.Start(presenterProgram, $""this.path" this.audioFormatParams[0] ((this.ckboxGenerate.Checked) ? "--create" : "") lang=this.languageCodesParams[this.cboxLanguage.SelectedIndex]");



Method 1:



private void BtnLaunchSDLApp_OnClick()

pVizualizer = Process.Start(audioSpectrumProgram); //file launched from local path (is correct)



Method 2:



pVizualizer = Process.Start(audioSpectrumBatchProgram); //file launched from local path (is correct)


Method 3:



ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
FileInfo spectrumFileInfo = new FileInfo(audioSpectrumProgram);
if (spectrumFileInfo.Exists)
info.Arguments = $"/c "spectrumFileInfo.FullName"";
pVizualizer = Process.Start(info);


Method 4:
based on senario of method 3. You don't have to parse arguments using ProcessStartInfo.



pVizualizer = Process.Start($"cmd.exe /K call "spectrumFileInfo.FullName"") //to observe what happens to the application


Edit #2



Not affected by changing the UseShellExecute to true or false



private void btnOpenVisualizer_Click(object sender, EventArgs e)

FileInfo spectrumFileInfo = new FileInfo(audioSpectrumProgram);
ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
info.UseShellExecute = true;
pVizualizer = new Process();
pVizualizer.StartInfo = info;
pVizualizer.EnableRaisingEvents = true;
pVizualizer.Exited += new EventHandler(myProcess_Exited);
pVizualizer.Start();


private void myProcess_Exited(object sender, System.EventArgs e)

Console.WriteLine(
$"Exit time : pVizualizer.ExitTimen" +
$"Exit code : pVizualizer.ExitCoden"
);










share|improve this question









New contributor




Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












Due to me having knowledge of launching apps I am aware that you have multiple ways of launching an application in C# .NET, but I'm running into a issue that occurs when attempting to launch a SDL2 application.



I have attempted the following using the Process class to:



  • Start the .exe file of the build.

  • Start the application using "cmd.exe /K" or "cmd.exe /c" followed by "exec" or "call" or "start" followed by "path to file" or "path to batch file to launch the application". Launching the application via a batch file and CMD works fine. But, whenever I attempt to even launch the application (even in a new instance of Command-Prompt launched from cmd.exe /? start cmd.exe ?params) it will yield no result.

What I can observe is that the application tries to open. It takes forever to launch into the Window mode (starting the 3D environment). After a timeout it will either, render a couple of frames of a blank window before closing or close immediately after opening the window.



So my question is, does anyone have succesfully made a launcher application for a SDL app written in C# .NET? Or knows a way to debug this behaviour? Because unfortunately, the app does not send out a error message and since SDL safely closes the application I can't observe a crash either.



Edit #1



I'm not doing anything fancy with parameters as there shouldn't be any. I already have another one functioning that launches a normal C# application as my launcher requires to open 2 programs. 1 SLD application, 1 COM:VBA controlling application.
Given:



string audioSpectrumProgram = "AudioSpectrum.exe";
string audioSpectrumBatchProgram = "AudioSpectrum.bat";

private void BtnLaunchPPTApp_OnClick()

//Powerpoint controlling application
pVBAApp = Process.Start(presenterProgram, $""this.path" this.audioFormatParams[0] ((this.ckboxGenerate.Checked) ? "--create" : "") lang=this.languageCodesParams[this.cboxLanguage.SelectedIndex]");



Method 1:



private void BtnLaunchSDLApp_OnClick()

pVizualizer = Process.Start(audioSpectrumProgram); //file launched from local path (is correct)



Method 2:



pVizualizer = Process.Start(audioSpectrumBatchProgram); //file launched from local path (is correct)


Method 3:



ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
FileInfo spectrumFileInfo = new FileInfo(audioSpectrumProgram);
if (spectrumFileInfo.Exists)
info.Arguments = $"/c "spectrumFileInfo.FullName"";
pVizualizer = Process.Start(info);


Method 4:
based on senario of method 3. You don't have to parse arguments using ProcessStartInfo.



pVizualizer = Process.Start($"cmd.exe /K call "spectrumFileInfo.FullName"") //to observe what happens to the application


Edit #2



Not affected by changing the UseShellExecute to true or false



private void btnOpenVisualizer_Click(object sender, EventArgs e)

FileInfo spectrumFileInfo = new FileInfo(audioSpectrumProgram);
ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
info.UseShellExecute = true;
pVizualizer = new Process();
pVizualizer.StartInfo = info;
pVizualizer.EnableRaisingEvents = true;
pVizualizer.Exited += new EventHandler(myProcess_Exited);
pVizualizer.Start();


private void myProcess_Exited(object sender, System.EventArgs e)

Console.WriteLine(
$"Exit time : pVizualizer.ExitTimen" +
$"Exit code : pVizualizer.ExitCoden"
);







c# .net sdl sdl-2






share|improve this question









New contributor




Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 16 hours ago









Uwe Keim

27.6k32132213




27.6k32132213






New contributor




Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 17 hours ago









Ryan van den BogaardRyan van den Bogaard

174




174




New contributor




Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Hi @Ryan and welcome to StackOverflow. I think there might be something wrong with the code which is used for launching the process. Could you please share that code to allow us to help you?

    – Just Shadow
    17 hours ago











  • Please add code you are using and not working. I suspect you passing parameters incorrectly.

    – Reniuz
    17 hours ago












  • It should technically be as simple as just launching the app as it does not utilise any params except for launching an Exec or Batch file from CMD instead of launching the process directly.

    – Ryan van den Bogaard
    17 hours ago











  • Oh yeah would like to emphasize that the application does in fact start. It's just that the SDL application that runs fine on its own and launched from a batch file or command prompt. It simply refuses to open a 3D environment when launched from another C# application, even if the LAUNCHER application is executing a call to start the process from an newly made CMD instance in C#. And no it can run side by side other C# applications if you'd think that this is the issue.

    – Ryan van den Bogaard
    16 hours ago












  • Have you tried to set UseShellExecute to false?

    – Reniuz
    16 hours ago

















  • Hi @Ryan and welcome to StackOverflow. I think there might be something wrong with the code which is used for launching the process. Could you please share that code to allow us to help you?

    – Just Shadow
    17 hours ago











  • Please add code you are using and not working. I suspect you passing parameters incorrectly.

    – Reniuz
    17 hours ago












  • It should technically be as simple as just launching the app as it does not utilise any params except for launching an Exec or Batch file from CMD instead of launching the process directly.

    – Ryan van den Bogaard
    17 hours ago











  • Oh yeah would like to emphasize that the application does in fact start. It's just that the SDL application that runs fine on its own and launched from a batch file or command prompt. It simply refuses to open a 3D environment when launched from another C# application, even if the LAUNCHER application is executing a call to start the process from an newly made CMD instance in C#. And no it can run side by side other C# applications if you'd think that this is the issue.

    – Ryan van den Bogaard
    16 hours ago












  • Have you tried to set UseShellExecute to false?

    – Reniuz
    16 hours ago
















Hi @Ryan and welcome to StackOverflow. I think there might be something wrong with the code which is used for launching the process. Could you please share that code to allow us to help you?

– Just Shadow
17 hours ago





Hi @Ryan and welcome to StackOverflow. I think there might be something wrong with the code which is used for launching the process. Could you please share that code to allow us to help you?

– Just Shadow
17 hours ago













Please add code you are using and not working. I suspect you passing parameters incorrectly.

– Reniuz
17 hours ago






Please add code you are using and not working. I suspect you passing parameters incorrectly.

– Reniuz
17 hours ago














It should technically be as simple as just launching the app as it does not utilise any params except for launching an Exec or Batch file from CMD instead of launching the process directly.

– Ryan van den Bogaard
17 hours ago





It should technically be as simple as just launching the app as it does not utilise any params except for launching an Exec or Batch file from CMD instead of launching the process directly.

– Ryan van den Bogaard
17 hours ago













Oh yeah would like to emphasize that the application does in fact start. It's just that the SDL application that runs fine on its own and launched from a batch file or command prompt. It simply refuses to open a 3D environment when launched from another C# application, even if the LAUNCHER application is executing a call to start the process from an newly made CMD instance in C#. And no it can run side by side other C# applications if you'd think that this is the issue.

– Ryan van den Bogaard
16 hours ago






Oh yeah would like to emphasize that the application does in fact start. It's just that the SDL application that runs fine on its own and launched from a batch file or command prompt. It simply refuses to open a 3D environment when launched from another C# application, even if the LAUNCHER application is executing a call to start the process from an newly made CMD instance in C#. And no it can run side by side other C# applications if you'd think that this is the issue.

– Ryan van den Bogaard
16 hours ago














Have you tried to set UseShellExecute to false?

– Reniuz
16 hours ago





Have you tried to set UseShellExecute to false?

– Reniuz
16 hours ago












2 Answers
2






active

oldest

votes


















1














Ok For Future reference:
Pathing to the files can be correct and everything might be in order but if you are using DLLs for imports. Change the process's working directory.



The project will run, libs can "sometimes" be found but can cause a weird unknown bug like this one. So the most optimal way of running another C# instance with SDL or any other kind of library:



 private void RunSDLProgram()

FileInfo spectrumFileInfo = new FileInfo("pathToFile.exe");
ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.UseShellExecute = false;
info.WorkingDirectory = spectrumFileInfo.DirectoryName;
pVizualizer = new Process();
pVizualizer.StartInfo = info;
pVizualizer.EnableRaisingEvents = true;
pVizualizer.Exited += new EventHandler(myProcess_Exited);
pVizualizer.Start();


private void myProcess_Exited(object sender, System.EventArgs e)

Console.WriteLine(
$"Exit time : pVizualizer.ExitTimen" +
$"Exit code : pVizualizer.ExitCoden" +
$"output : pVizualizer.StandardOutputn" +
$"err : pVizualizer.StandardErrorn"
);



Running a batch file will look at it's own directory and makes all references local, but it won't alter the working directory. (already had my suspicions about changing the work directory but I didn't see a way to call 2 opperations in process.start("cmd.exe");)






share|improve this answer








New contributor




Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    1














    A general way of analyzing startup issues is to use SysInternals Process Monitor.



    Record the application that is not starting up properly. Use a filter for your application. Then go through all items which don't have SUCCESS in the result column. Typically you want to do that bottom-up, since the last error is the one stopping your application from loading.



    Like this you'll find common startup issues like:



    • missing DLLs or other dependencies

    • old DLLs or DLLs loaded from wrong location (e.g. registered COM components)

    • wrong working directory, e.g. access to non-existent config files





    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Ryan van den Bogaard is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021218%2flaunching-c-sharp-program-from-another-c-sharp-program%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Ok For Future reference:
      Pathing to the files can be correct and everything might be in order but if you are using DLLs for imports. Change the process's working directory.



      The project will run, libs can "sometimes" be found but can cause a weird unknown bug like this one. So the most optimal way of running another C# instance with SDL or any other kind of library:



       private void RunSDLProgram()

      FileInfo spectrumFileInfo = new FileInfo("pathToFile.exe");
      ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
      info.RedirectStandardOutput = true;
      info.RedirectStandardError = true;
      info.UseShellExecute = false;
      info.WorkingDirectory = spectrumFileInfo.DirectoryName;
      pVizualizer = new Process();
      pVizualizer.StartInfo = info;
      pVizualizer.EnableRaisingEvents = true;
      pVizualizer.Exited += new EventHandler(myProcess_Exited);
      pVizualizer.Start();


      private void myProcess_Exited(object sender, System.EventArgs e)

      Console.WriteLine(
      $"Exit time : pVizualizer.ExitTimen" +
      $"Exit code : pVizualizer.ExitCoden" +
      $"output : pVizualizer.StandardOutputn" +
      $"err : pVizualizer.StandardErrorn"
      );



      Running a batch file will look at it's own directory and makes all references local, but it won't alter the working directory. (already had my suspicions about changing the work directory but I didn't see a way to call 2 opperations in process.start("cmd.exe");)






      share|improve this answer








      New contributor




      Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























        1














        Ok For Future reference:
        Pathing to the files can be correct and everything might be in order but if you are using DLLs for imports. Change the process's working directory.



        The project will run, libs can "sometimes" be found but can cause a weird unknown bug like this one. So the most optimal way of running another C# instance with SDL or any other kind of library:



         private void RunSDLProgram()

        FileInfo spectrumFileInfo = new FileInfo("pathToFile.exe");
        ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
        info.RedirectStandardOutput = true;
        info.RedirectStandardError = true;
        info.UseShellExecute = false;
        info.WorkingDirectory = spectrumFileInfo.DirectoryName;
        pVizualizer = new Process();
        pVizualizer.StartInfo = info;
        pVizualizer.EnableRaisingEvents = true;
        pVizualizer.Exited += new EventHandler(myProcess_Exited);
        pVizualizer.Start();


        private void myProcess_Exited(object sender, System.EventArgs e)

        Console.WriteLine(
        $"Exit time : pVizualizer.ExitTimen" +
        $"Exit code : pVizualizer.ExitCoden" +
        $"output : pVizualizer.StandardOutputn" +
        $"err : pVizualizer.StandardErrorn"
        );



        Running a batch file will look at it's own directory and makes all references local, but it won't alter the working directory. (already had my suspicions about changing the work directory but I didn't see a way to call 2 opperations in process.start("cmd.exe");)






        share|improve this answer








        New contributor




        Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






















          1












          1








          1







          Ok For Future reference:
          Pathing to the files can be correct and everything might be in order but if you are using DLLs for imports. Change the process's working directory.



          The project will run, libs can "sometimes" be found but can cause a weird unknown bug like this one. So the most optimal way of running another C# instance with SDL or any other kind of library:



           private void RunSDLProgram()

          FileInfo spectrumFileInfo = new FileInfo("pathToFile.exe");
          ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
          info.RedirectStandardOutput = true;
          info.RedirectStandardError = true;
          info.UseShellExecute = false;
          info.WorkingDirectory = spectrumFileInfo.DirectoryName;
          pVizualizer = new Process();
          pVizualizer.StartInfo = info;
          pVizualizer.EnableRaisingEvents = true;
          pVizualizer.Exited += new EventHandler(myProcess_Exited);
          pVizualizer.Start();


          private void myProcess_Exited(object sender, System.EventArgs e)

          Console.WriteLine(
          $"Exit time : pVizualizer.ExitTimen" +
          $"Exit code : pVizualizer.ExitCoden" +
          $"output : pVizualizer.StandardOutputn" +
          $"err : pVizualizer.StandardErrorn"
          );



          Running a batch file will look at it's own directory and makes all references local, but it won't alter the working directory. (already had my suspicions about changing the work directory but I didn't see a way to call 2 opperations in process.start("cmd.exe");)






          share|improve this answer








          New contributor




          Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.










          Ok For Future reference:
          Pathing to the files can be correct and everything might be in order but if you are using DLLs for imports. Change the process's working directory.



          The project will run, libs can "sometimes" be found but can cause a weird unknown bug like this one. So the most optimal way of running another C# instance with SDL or any other kind of library:



           private void RunSDLProgram()

          FileInfo spectrumFileInfo = new FileInfo("pathToFile.exe");
          ProcessStartInfo info = new ProcessStartInfo(spectrumFileInfo.FullName);
          info.RedirectStandardOutput = true;
          info.RedirectStandardError = true;
          info.UseShellExecute = false;
          info.WorkingDirectory = spectrumFileInfo.DirectoryName;
          pVizualizer = new Process();
          pVizualizer.StartInfo = info;
          pVizualizer.EnableRaisingEvents = true;
          pVizualizer.Exited += new EventHandler(myProcess_Exited);
          pVizualizer.Start();


          private void myProcess_Exited(object sender, System.EventArgs e)

          Console.WriteLine(
          $"Exit time : pVizualizer.ExitTimen" +
          $"Exit code : pVizualizer.ExitCoden" +
          $"output : pVizualizer.StandardOutputn" +
          $"err : pVizualizer.StandardErrorn"
          );



          Running a batch file will look at it's own directory and makes all references local, but it won't alter the working directory. (already had my suspicions about changing the work directory but I didn't see a way to call 2 opperations in process.start("cmd.exe");)







          share|improve this answer








          New contributor




          Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered 15 hours ago









          Ryan van den BogaardRyan van den Bogaard

          174




          174




          New contributor




          Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Ryan van den Bogaard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.























              1














              A general way of analyzing startup issues is to use SysInternals Process Monitor.



              Record the application that is not starting up properly. Use a filter for your application. Then go through all items which don't have SUCCESS in the result column. Typically you want to do that bottom-up, since the last error is the one stopping your application from loading.



              Like this you'll find common startup issues like:



              • missing DLLs or other dependencies

              • old DLLs or DLLs loaded from wrong location (e.g. registered COM components)

              • wrong working directory, e.g. access to non-existent config files





              share|improve this answer



























                1














                A general way of analyzing startup issues is to use SysInternals Process Monitor.



                Record the application that is not starting up properly. Use a filter for your application. Then go through all items which don't have SUCCESS in the result column. Typically you want to do that bottom-up, since the last error is the one stopping your application from loading.



                Like this you'll find common startup issues like:



                • missing DLLs or other dependencies

                • old DLLs or DLLs loaded from wrong location (e.g. registered COM components)

                • wrong working directory, e.g. access to non-existent config files





                share|improve this answer

























                  1












                  1








                  1







                  A general way of analyzing startup issues is to use SysInternals Process Monitor.



                  Record the application that is not starting up properly. Use a filter for your application. Then go through all items which don't have SUCCESS in the result column. Typically you want to do that bottom-up, since the last error is the one stopping your application from loading.



                  Like this you'll find common startup issues like:



                  • missing DLLs or other dependencies

                  • old DLLs or DLLs loaded from wrong location (e.g. registered COM components)

                  • wrong working directory, e.g. access to non-existent config files





                  share|improve this answer













                  A general way of analyzing startup issues is to use SysInternals Process Monitor.



                  Record the application that is not starting up properly. Use a filter for your application. Then go through all items which don't have SUCCESS in the result column. Typically you want to do that bottom-up, since the last error is the one stopping your application from loading.



                  Like this you'll find common startup issues like:



                  • missing DLLs or other dependencies

                  • old DLLs or DLLs loaded from wrong location (e.g. registered COM components)

                  • wrong working directory, e.g. access to non-existent config files






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 14 hours ago









                  Thomas WellerThomas Weller

                  28.8k1066138




                  28.8k1066138




















                      Ryan van den Bogaard is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      Ryan van den Bogaard is a new contributor. Be nice, and check out our Code of Conduct.












                      Ryan van den Bogaard is a new contributor. Be nice, and check out our Code of Conduct.











                      Ryan van den Bogaard is a new contributor. Be nice, and check out our Code of Conduct.














                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021218%2flaunching-c-sharp-program-from-another-c-sharp-program%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      1928 у кіно

                      Захаров Федір Захарович

                      Ель Греко