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#

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

Why is my Contribution Detail Report (native CiviCRM Core report) not accurate?

How do I deal with being envious of my own players?

Is divide-by-zero a security vulnerability?

Difference between 'stomach' and 'uterus'

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

Rationale to prefer local variables over instance variables?

The Ohm's law calculations of the parts do not agree with the whole

“I had a flat in the centre of town, but I didn’t like living there, so …”

1970s scifi/horror novel where protagonist is used by a crablike creature to feed its larvae, goes mad, and is defeated by retraumatising him

Is there a way to find out the age of climbing ropes?

When do _WA_Sys_ statistics Get Updated?

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

Must 40/100G uplink ports on a 10G switch be connected to another switch?

How does signal strength relate to bandwidth?

How to merge row in the first column in LaTeX

Formatting a table to look nice

Misplaced tyre lever - alternatives?

Correct physics behind the colors on CD (compact disc)?

Every subset equal to original set?

Draw bounding region by list of points

Do AL rules let me pick different starting equipment?

If nine coins are tossed, what is the probability that the number of heads is even?

Make me a metasequence



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
    12 hours ago











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

    – Reniuz
    12 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
    11 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
    11 hours ago












  • Have you tried to set UseShellExecute to false?

    – Reniuz
    11 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
    12 hours ago











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

    – Reniuz
    12 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
    11 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
    11 hours ago












  • Have you tried to set UseShellExecute to false?

    – Reniuz
    11 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 10 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 12 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
    12 hours ago











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

    – Reniuz
    12 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
    11 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
    11 hours ago












  • Have you tried to set UseShellExecute to false?

    – Reniuz
    11 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
    12 hours ago











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

    – Reniuz
    12 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
    11 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
    11 hours ago












  • Have you tried to set UseShellExecute to false?

    – Reniuz
    11 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
12 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
12 hours ago













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

– Reniuz
12 hours ago






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

– Reniuz
12 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
11 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
11 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
11 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
11 hours ago














Have you tried to set UseShellExecute to false?

– Reniuz
11 hours ago





Have you tried to set UseShellExecute to false?

– Reniuz
11 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 10 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 9 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

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                      Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                      2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived