How to start an XNA game with another C # program

So, I recently started trying to use an XNA program to run another XNA program. I use the regular "Process.Start" method, which works great when opening Firefox or Media Player. However, when I try to run any XNA program (I tried several), I get the error message "No suitable graphics card was found. Unable to create a graphics device. This program requires a pixel shader 1.1 and vertex shader 1.1." I acknowledge this as an error when the graphics device cannot process XNA, but this is not a problem here, since I am already starting XNA to start.

Currently my code is as follows:

System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = Stat.clientfile; process.StartInfo.Arguments = ""; process.StartInfo.LoadUserProfile = true; process.StartInfo.UseShellExecute = false; process.StartInfo.WorkingDirectory = Stat.clientfile.Remove(Stat.clientfile.Length - 1 - Stat.clientfile.Split(Convert.ToChar(@"\"))[Stat.clientfile.Split(Convert.ToChar(@"\")).Length - 1].Length); process.StartInfo.RedirectStandardOutput = true; Stat.MessageBox(process.StartInfo.WorkingDirectory); process.Start(); 

But after I tried almost every addition to Process.Start(filename) , I could think. I am running XNA 3.1 on Acer Netbook if that means anything.

If someone understands what is wrong with this, your help will be greatly appreciated!

+4
source share
2 answers

I ran into the same problem. I found this thread:

http://forums.create.msdn.com/forums/p/94466/566353.aspx

Below, Kezip says: " XNA did not allow multiple programs to run while one was in full-screen mode ." Resolving a problem with both programs from full screen mode.

+2
source

You cannot use

 process.StartInfo.RedirectStandardOutput = true; 

with XNA applications.

Why? An XNA application will attempt to create an INSIDE graphics device for another XNA process in such a way that it fails 100%.

Do not redirect the output and it will work. (Worked for me in two test scenarios with XNA 4.0 - I can’t say 100% if this is the same in 3.1)

EDIT:

By the way, you better use this to create your working directory

 process.StartInfo.WorkingDirectory = Stat.clientfile.Substring(0, Stat.clientfile.LastIndexOf('\\')); 
0
source

Source: https://habr.com/ru/post/1379355/


All Articles