Reputation: 21
First - I am newbie on this website so I am carefull on begginning.
I have a problem with my process. I want to start it as 32 - 64 bit process no only 64 bit. I try changing debug configurations in my Visual Studia 2010 on AnyCPU, x64, x86 but it doesn't work.
My Code is here:
public static void startMinecraft(bool mode, string ramMax, string ramMin, string username, string sessionID, bool debug, string javafold, string mainfolder, string server)
{
string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\";
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\";
Process proc = new Process();
proc.StartInfo.UseShellExecute = false;
if (Environment.Is64BitProcess)
{
MessageBox.Show("yes"); // it is always yes
}
else
{
MessageBox.Show("no");
}
if (proc.StartInfo.EnvironmentVariables.ContainsKey("APPDATA"))
proc.StartInfo.EnvironmentVariables["APPDATA"] = @appData + mainfolder + "\\" + server;
else
proc.StartInfo.EnvironmentVariables.Add("APPDATA", @appData + mainfolder + "\\" + server);
if (debug == true)
{
proc.StartInfo.FileName = @appData + javafold + "\\jre\\bin\\java.exe";
}
else
{
proc.StartInfo.FileName = @appData + javafold + "\\jre\\bin\\javaw.exe";
}
//Online and offline modes
if (mode == true)
{
proc.StartInfo.Arguments = "-cp \"" + appData + mainfolder + "/.minecraft/bin/minecraft.jar;" + appData + mainfolder + "/.minecraft/bin/lwjgl.jar;" + appData + mainfolder + "/.minecraft/bin/lwjgl_util.jar;" + appData + mainfolder + "/.minecraft/bin/jinput.jar;\" ";
proc.StartInfo.Arguments += "\"-Djava.library.path=" + appData + mainfolder + "/.minecraft/bin/natives\" -Xmx" + ramMax + "M -Xms" + ramMin + "M net.minecraft.client.Minecraft " + username + " " + sessionID;
}
else
{
proc.StartInfo.Arguments = "-cp \"" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\minecraft.jar;" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\lwjgl.jar;" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\lwjgl_util.jar;" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\jinput.jar;\" ";
proc.StartInfo.Arguments += "\"-Djava.library.path=" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\natives\" -Xmx" + ramMax + "M -Xms" + ramMin + "M -XX:MaxPermSize=256m net.minecraft.client.Minecraft " + username;
}
proc.Start();
}
This process works perfectly but only on 64 bit OS platforms.
Error on 32 bit OS is:
System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at WindowsFormsApplication1.Form1.startMinecraft(Boolean mode, String ramMax, String ramMin, String username, String sessionID, Boolean debug, String javafold, String mainfolder, String server)
at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) etc...
Thanks for all help! And sorry for my mistakes in english.
Upvotes: 1
Views: 2753
Reputation: 6590
If I interpret the stacktrace correctly the problem lies not within your application but the application you are trying to execute. So your java.exe
and/or javaw.exe
seem to be running on 64 bit only.
Upvotes: 0
Reputation: 423
You should just consider making a 32 bit exe, this will work on 32 and 64
Upvotes: 2