|
I have an update process in my app that downloads an installer and runs it. If the user cancels the installer it throws a Win32Exception. The problem is that in the Catch all I get is the Exception with the message "The operation was cancelled by the user". Other than the text of the message, there's really no way to know for sure what exception occurred. I don't want to rely on the exception message.
Any way to trap this specific issue?
Here's my code:
private static void StartInstaller()
{
try
{
_ = Process.Start(_localSetupFile);
Process[] processes;
do
{
processes = Process.GetProcessesByName(_processName);
Thread.Sleep(1000);
}
while (processes.Length == 0);
}
catch (Win32Exception e)
{
}
catch (Exception e)
{
throw;
}
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Is the installer an .MSI?
|
|
|
|
|
Have you looked at ClickOnce? I have a Silent Updater for .Net Framework v3.5+ that takes out all of the hard work: Silent ClickOnce Installer for Winform & WPF in C# & VB[^]. If your app is Dot Net Core Framework, I have a new article that I will release very soon, just need to finish the article writeup.
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
|
|
|
|
|
Win32Exception has a NativeErrorCode property which should return 1223 (0x4C7) when the user stops a process starting at a UAC prompt.
An example from my own code where I do something similar is probably clearer than more words!
private static void RestartWithRunAs(ProcessStartInfo psi) {
psi.UseShellExecute = true;
psi.ErrorDialog = true;
psi.Verb = "runas";
try {
Process.Start(psi);
} catch (System.ComponentModel.Win32Exception exc) {
const Int32 CancelledByUser = 1223;
if (exc.NativeErrorCode != CancelledByUser) {
throw;
}
}
}
See also
System Error Codes (1000-1299) (WinError.h) - Win32 apps | Microsoft Learn[^]
Alan.
|
|
|
|
|
Thanks. I'll give it a try
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
If this is not allowed please delete...
I'm looking for a programmer that can help me with a c# program I've started.
It's a CAD style program to design simple framework structures.
It's not a project for a larger development company, and I've tried websites that advertise professionals.
Mostly looking for help, but if someone is available to do more thats great too!!
Thanks,
Tom
|
|
|
|
|
This is not a recruitment site: I suggest you go to Freelancer.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Understood. That's why I began with delete if not permitted.
Not trying to recruit or poach. looking for help with a program I'm writing.
|
|
|
|
|
There is also Fiverr[^] and Triplebyte[^]. The last one looks better than Fiver or Freelancer.
Hope this helps.
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
|
|
|
|
|
I've just noticed a new icon at the bottom right of CP messages. Just before the orange ribbon icon (bookmark this) and red flag icon (abusive / inappropriate / spam) there is now a bent black arrow icon. I haven't risked clicking it as there is no tooltip to say what it does. Does anyone know what is it for?
|
|
|
|
|
It just appears to be another way to get a link to the current message.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks!
It does not seem to save any keystroke / mouse actions:
Old way
1) Right click message title in hierarchical list of topics
2) Select 'Copy Link' from popup menu
New way
1) Left click new arrow icon
2) Ctrl-C to copy the link
I'll request a tooltip to show what it does in 'Bugs and Suggs' (if no one has beaten me to it) as it is not intuitive
|
|
|
|
|
From the brief description is that I know there are a lot of existing applications, commercial and free that could already be described that way. So if you think you have a new product idea then hopefully you researched what is out there already.
If you just want to create this for yourself then you can create an open source site, start the code and then attempt by posting at other sites to convince others to contribute. But like the previous suggestion you need a vision that makes your idea (goal) unique.
If you are looking for a mentor then the scope of what you are attempting (again from the description) is not all that small so I am not sure you would find that just by looking online. Rather a heavy commitment. But perhaps paying for it as suggested might work. But you need to be specific about the mentoring part.
|
|
|
|
|
TBH, help is what I would like the most.
I'm in a very small industry.
It's more application specific and tools for what I do, is what I need.
I've written several LISP routines for AutoCAD that help however It only goes so far.
It's true a full CAD program is a huge commitment.
What I need is help with a few things, but I value peoples knowledge and time.
That's why the offer to hire a programmer. Never wanting to insult anyone's abilities.
Thanks!!
|
|
|
|
|
If the project is small enough then you should be able to hack your way through it with time.
If you know it isn't small then your choices are limited to the following
1. As I suggested, open source the site and then attempt to drum up interest.
2. Stop attempting to create the product and instead create a company that will build the product. You describe it and others build it. If the need exists in the 'small industry' and there is in fact a need and a way to monetize it then it should be possible to find someone to provide the seed capital to build it. Then instead of you building it you hire one or two others to build it. You will also need to find someone to sell it.
|
|
|
|
|
This will make more sense if my other message goes through.
But I'm also kind of embarrassed by my lack of knowledge.
What I've written so far does a lot but I struggle with understanding what feels like should be basic knowledge....
|
|
|
|
|
Here's a thought: since this is a "help" site (among other things), why don't you ask some "technical" questions that may give you some traction on your project instead of simply trying to hire a programmer, blind. The surest way to get scammed is to be as ignorant of the "true" nature of your project as possible.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Hello community,
Looking for new contacts in Freiburg who want to work with me on an 8-bit music studio.
[Version]
[x] Smartphones and IPhones
[x] Standalone for Windows, Linux and MAC
[x] VST plugin
[Need Help]
[x] Musicians & DJ who like 8bit sounds are very welcome.
[x] .Net programmer for Linux, Windows and Mac
[using]
[x] GeorgRottensteiner SharpSid
[x] NAudio
[x] VST.NET
[x] sfxr
Greetings
Eric
|
|
|
|
|
Then you need to go to freelancers.com, or similar. This website is for specific technical discussions and questions.
|
|
|
|
|
This is not a recruitment site: I suggest you go to Freelancer.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
And to find a developer in a specific town? A global website is probably not the best place to start ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'd start with related "clubs" in Freiburg. This is pretty abstract for remote work. i.e. high risk of failure.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
kiri008 wrote: in Freiburg
Presumably a city.
Presumably you want to interact with people directly.
So you will want to look to schools. Universities and high schools (whatever they are called there with student ages from about 14 to 18 years old.)
People interested in both music and computers.
You should take into account that enthusiasm is NOT the same as drive, dedication, willingness to work and deliver. So go into knowing that many contacts that seem like they want to do it will soon disappear and/or will never actually produce anything.
If you skip the need to for the personal interaction then you can create your own online open source project and then try to drum up interest (contributors) by publishing on other sites. However to be fair I would be very surprised if there were not already quite a few other projects out there doing the same thing - perhaps you should find one and contribute to it instead.
Also be careful about starting off too big. Start with the smallest project that does something and then add to it once that is completed.
|
|
|
|
|
Hi, everyone.
I´ve developped a C# program and I have a problem with configuration file.
I use Visual Studio 2022 and Windows 10.
To start, the program acesses the configuration file to read some information, then, after the user enters username and password the program grants (or not) use and opens main screen.
In config file there are information about server name and DB name. Everything worked fine until some days ago. I made some changes in config file (I removed a variable) and, in my computer it works, but in another computer it does't anymore.An exception appears about connection to DB which is closed. After many prints I foud out that the program is using variables not from the config file, and I don1t know where it comes from. I have also another program which deals with this config file. This file also can't access config file correctly.
Here is a snippet of the code of this second file:
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = Base.caminho + Base.nomeArquivo + ".exe.config";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
string Banco = config.AppSettings.Settings["Tipo"].Value;
string Servidor = config.AppSettings.Settings["Servidor"].Value;
string Empresa = config.AppSettings.Settings["Empresa"].Value;
string Local = config.AppSettings.Settings["Local"].Value;
string Diretorio = config.AppSettings.Settings["Pasta"].Value;
MessageBox.Show("Arquivo de configuração = " + fileMap.ExeConfigFilename + "\nServidor = " + Servidor + " Empresa = " + Empresa + " Local = " + Local +
"\nDiretório = " + Diretorio + " Banco = " + Banco);
if (!VerificaBasedeDados(Banco))
{
MessageBox.Show("Base de dados " + Banco + " inexistente!");
return;
}
In the first MessageBox.Show, the variable Banco (which is the DB name) is different from what is in the config file!
The 'if' after tests if the DB exists, but the program crashes before it.
The curious thing here is that in my computer it runs OK. In other computers it doesn't (I tried in 2). And before that change it ran OK too!
I tried to include back the variable but it didn't work.
Does anyone have any ideas?
Thanks.
|
|
|
|
|
Since you're calling OpenMappedExeConfiguration , I'm guessing that your code is writing to the config file at some point.
(If it's not, then why not simply use ConfigurationManager.AppSettings ?)
I'm also guessing that your users have installed your application in the "Program Files" directory; that your application doesn't run elevated; that your application is 32-bit; and that your application doesn't contain a manifest with a "requested execution level" attribute.
In which case, the users won't have permission to write to the config file, and you'll be hitting UAC virtualization:
How User Account Control works (Windows) | Microsoft Learn[^]
There will be a copy of the config file at a particular location within the user's profile, and that's what your application will be reading.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi, Richard.
Your assumptios are correct. Notice that users had access to the program and everything was fine. The configuration program (which is used to change parameters in config file) also worked without problem in my computer and in the other computers. After I made some changes (I remove one parameter) both programs stopped working in the other computers, but continue to work fine in mine. Maybe, as you say, some permissions were changed, but I have no idea of what was it. What do you suggest me to see in that article?
Thank you.
|
|
|
|