Вопрос

I've got a tiny Portal I´m writing, and this portal is supposed to launch installers on button click. I´m developing on VS2010 on a WinXP SP3 station, and on this machine, even fter compilation and publishing, everything works as expected. However, when i run the compiled application in Windows 7, it crashes...The application work, it just crashes when i click a button for program installation.

The programming looks like this:

    private void button_access_Click(object sender, RoutedEventArgs e)
    {


        Process executable = new Process();
        string executablePath = "D:\\Visual Studio 2010\\SAFE_Portal1\\SAFE_Portal1\\Extra Programs\\AccessRT2003.exe";
        executable.StartInfo.FileName = executablePath;
        executable.Start();


    }

It specifically crashes on thr button_access_Click procedure...

Any ideas as to why this could be? I`ve tried looking around here in Stackoverflow, and in other forums, but to no avail...

Any help or direction is ganz welcome!

Это было полезно?

Решение

Try this:

try
{
     Process executable = new Process();
     string executablePath = "D:\\Visual Studio 2010\\SAFE_Portal1\\SAFE_Portal1\\Extra Programs\\AccessRT2003.exe";
     executable.StartInfo.FileName = executablePath;
     executable.Start();
 }
 catch (Exception msg)
 {
     MessageBox.Show(msg.Message);
 }

What message are you getting?

Are you sure you want to use fixed paths in your application? If so you should at least check if the file you try to start exists beforehand. Otherwise an exception will be thrown which could be the problem here.

if (File.Exists(executablePath))
{
    ...
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top