E
E
ebaysher2021-06-19 10:52:31
.NET
ebaysher, 2021-06-19 10:52:31

How to change the bitness of a .net application?

static void Main(string[] args)
        {
            StartProcess();
        }
static void StartProcess()
        {
          Process.Start("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", "https://www.google.com");
        }


When I specify absolute, the path is ok. If you run from another PC, then the path may be different. When I specify a relative path, an exception is thrown. On one forum, they suggested that the matter was in the capacity of the application.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
d-stream, 2021-06-19
@ebaysher

Digitization is definitely not in business here.
As already noted - Start requires an explicit path to the launcher (otherwise, they may well slip something completely different).
To "bypass" the restriction in the form of a mandatory explicit path, you can use several options:
- run cmd.exe specifying the application to be launched in the parameters - it will only help if the application is located anywhere, but it is registered in the path
- shovel the file system and find a specific path to the application ( Directory.GetFiles) - there may be several applications and you will have to make a choice
- check for availability in the expected places and ask the user if not, and then save it for subsequent launches
p / s / you can still dig into the registry to check for installed programs and get the path from there

V
Vasily Bannikov, 2021-06-19
@vabka

On one forum, they suggested that the matter was in the bitness of the application.

It's interesting, and here the bitness in general.
When I specify a relative path, an exception is thrown.

A relative path will only solve the problem if chrome is installed in the same folder as your application. Now it is often placed in the user's local folder.
There are several options:
1. Ask the user to explicitly specify the path to chrome
2. Run the default browser. To do this, you just need to enter it Process.Start("https://www.google.com");
. But it seems to only work on Windows
3. Drag the chrome binaries instead of with your application.
4. Iterate over all possible paths to chrome: both Program Files, and Program Files (x86), and AppData

N
none7, 2021-06-19
@none7

Project properties
Target = "Any CPU"
Prefer 32-bit = false
vs2015_proppage_build.png?view=vs-2019
In general, it's good practice to launch the default browser by specifying the URL itself instead of the path to the program and setting the UseShellExecute=true property. If you want to provide a browser choice, then you need to get into HKEY_CLASSES_ROOT and pull out a list of handlers from it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question