C# .NET Service is not starting after a Windows Shut Down (but it does after a Restart?) - service

Recently I build a C# .NET Windows Service, which actually does exactly what it should do. So, no problem there.
BUT... When I start my PC again after a SHUT DOWN (Windows button), and I look immediately in the Services list then I notice every time that my service shows as "running" already.
(Only for this purpose I set my service to "delayed start", which gives me a minute or two)
All other delayed start services in the list are still NOT running at that moment, as it should be.
Obviously my service does NOT work at all in this situation and is completely useless.
However, when I do a Windows RESTART (Windows button), everything works normal and fine.
Even when I shut down the PC by pressing the hardware power button for a few seconds, after a power-up everything works just fine.
I tried the same service on my laptop with exactly the same result.
This latest is not the only service I made. I tried to build several different services, unfortunately all with the same result.
The service is based on this tutorial:
https://learn.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer
On both my PC and my laptop I use the latest update of Windows10 and the latest update of Visual Studio 2022.
Anyone maybe noticed a similar behavior?
Any help would be greatly appreciated.
Cheers!
Peter
P.S. I start to believe this behavior is due to a Windows bug (thanks Bill), since I also noticed that WakeOnLAN after SHUT DOWN (Windows button) randomly reboots the PC several times at night.
However when I shut down the PC with the hardware power button it keeps quiet.
But that is another issue and doesn't belong here.

Related

Developing Flutter with VSCode and WSL2

Since I mostly develop Web, using nginx, PHP and MySQL, I have ported my WebDev-environment entirely to WSL2.
Since performance is very important, all my web-related projects reside on the WSL2-vhdx file /home/user/Projects/Web. In WSL2 I've installed all my necessary tools for a nice and neat Linux-like experience, Docker, GIT, etc.. This combined with VSCode remote integration works very well.
Now, I'm digging into building Flutter-Apps, and my Flutter-environment is installed on the Windows side. My Flutter-related projects reside on D:\Projects\Flutter which is a partition, and NOT USED in WSL2 in any way. Building Flutter-apps with flutter-windows-sdk and VSCode works neatly.
But, the problem is: Now I've my project files scattered all across my computer. Web-stuff in a WSL2-vhdx-file and Flutter-stuff on the D-partition.
Is there a way to build flutter-apps with Flutter, while having the project-files stored on a WSL2-vhdx-file, in combination with VSCode-remote and an Android-emulator?
I tried creating a test Flutter-project on the \\wsl$ network mount, which didn't work.
Moving my web-related project files to the D:\ partition of Windows is no option, since the I/O mounts in WSL2 are extremely slow.
I got it working, reliably with adb connect 192.168.xxx
For anyone interested, see my full blog post here: https://dnmc.in/2021/01/25/setting-up-flutter-natively-with-wsl2-vs-code-hot-reload/
Is there a way to build flutter-apps with Flutter, while having the project-files stored on a WSL2-vhdx-file, in combination with VSCode-remote and an Android-emulator?
I'm assuming (based on the mention of VS Code Remoting) that you want to run the extension in WSL. I haven't tried that specifically, but I have run Flutter inside WSL and also connected a VS Code Remoting session to an Android emulator in the cloud, so I would expect this to work.
You'll need to make sure you set up the Flutter SDK inside WSL (so you can run flutter commands inside WSL - it should be the Linux version of the Flutter SDK and not the Windows one if you're using the zip).
To have your emulator show up in flutter devices from inside WSL, you will likely need to run adb tcpip 5555 from the Windows side (this means you need an Android SDK in Windows) - this will tell your phone to listen on TCP port 5555. Then you'll need to run adb connect [phone ip]:5555 from inside WSL (this means you'll need an Android SDK in Linux). If all goes well, the phone should then show up in adb devices and also be picked up by the device selector in VS Code.
I tried creating a test Flutter-project on the \wsl$ network mount, which didn't work.
It's not clear what went wrong here, though my first guess would be that maybe the UNC path isn't supported - if you map a drive letter to it does it make a difference?
While this isn't an officially supported setup, feel free to raise issues in the Dart-Code repository on GitHub with any issues you have. It's not a priority, but I would like for VS Code Remoting (including WSL and Docker) to generally work for Dart and Flutter dev.
Anytime you're crossing/sharing the file-system boundary from windows to wsl you're paying a massive cost in speed/time.
With the setup you've described I'd consider trying to self-host the browser based VSCode.dev inside wsl - checkout details instructions here: https://medium.com/geekculture/3-steps-to-code-from-anywhere-45401247f479
Personally I've settled on running VSCode and docker inside a Linux VM on Windows, and have a 96% time saving in things like running up a server and watching code for changes making this setup my preferred way now.
The standardisation of devcontainer.json and being able to use github codespaces if you're away from your normal dev machine make this whole setup a pleasure to use.
see https://stackoverflow.com/a/72787362/183005 for detailed timing comparison and setup details

Why won't my Click-Once app install?

I have an app I wrote in WPF, which I publish by right-clicking on the project in Visual Studio 2013. This produces a set of files which I zip up and make available for users to download and install.
This has been working fine for a while, but today a user told me that he can't install the latest version. It gets as far as the install dialog, then just hangs there. If you kill the install, the app doesn't show up in the list of installed programs, but in Task Manager, I can see that the app itself is actually running, but has three instances running. I can't kill any of these, and have to restart the machine.
He's using Windows 7 Home Premium if it makes any difference.
I've tried uninstalling the old version and restarting his machine several times, but it doesn't help. The app installed fine on my machine, and as far as I know, nothing has changed on his machine.
Any ideas what's gone wrong? Don't know if I missed out any important details. If so, please let me know and I'll fill them in.
In case it helps anyone, it turned out to be to do with the certificate. I thought I was using one, but his machine seemed to think I wasn't. We had to turn off UAC and then right-click the exe to unblock it. That got him going.
I'm fed up with Click-once. it's been nothing but trouble. I've been playing with InnoSetup, which works really well and doesn't have all these problems. It's also pretty easy to make the app update itself automatically without driving the users mad.
Hope this helps someone.

Failing Direct3D test in WACK

I'm building a Windows Store app and I'm failing the App Certification Tool test for the Direct3D feature. This is a general app with no specific calls to any graphics feature.
I've tried running the tests on two different machines so I don't think my problem is hardware specific. More, I've tried testing a very basic app stripped of all UI controls except for a text block and I'm receiving the same error. The machines are running RTM builds of Windows 8 and VS2012.
Essentially, I'm asking, what should I look at next to resolve this issue?
Thanks--
Installing all available Windows Updates and try to run WACK again.
I had luck with this method on more than one machine. Apparently, pending updates cause the issue. install the updates, let the machine restart and finish the updating process. The issue should be gone after that.

OSGi headless deployment on Linux

I've developed a OSGi application on my windows machine that is just lovely. How ever I need it to run on my Linux server and this is where I run into problems.
My application has no GUI. It simple works with a console and is command line driven.
My first attempt at deployment I built a product based on my existing run target. It exported fine to a Windows .exe so I added the required delta packs for Linux. The problem with this is it has only two options Linux (GTK) and Linux (MOTIF). My linux server runs on CentOS with no GUI as it is a hosted machine so when I try and deploy it I get a segmentation fault.
I have been searching around as to what to do but I'm not coming up with any answers.
Any help would be much appreciated. I have been banging my head on this one for over a week
Cheers
The google keyword you need is 'xvfb' - it acts like an X server, but ignores everything sent to it, so you don't need any graphics hardware. Try firing that up (make sure you set DISPLAY appropriately).
A cleaner solution would be to figure out why the library is demanding an X server if it works without - perhaps you could update the question with more details.

Why is VPN connection on Mac OS X causing Eclipse to lockup during 'edit launch config' operation?

I have been using Eclipse on Mac OS X from home over a VPN to develop GWT and perl code in a local workspace for my employer. Recently a repeatable and severe lockup began occurring whenever I tried to edit Debug (or Run) launch configurations. I got the spinning beachball of death (SBOD) and, if I waited long enough (10-15 minutes) it would eventually stop and I could at least close the dialog.
I tried numerous things until a coworker suggested trying it with VPN turned off. To my surprise (and somewhat delight) it began behaving normally in the above scenario. I have been using Eclipse in this manner for about a year with no problems so naturally I am racking my brain trying to think of recent changes to VPN and/or to my split tunnel script (euphemistically called 'multihome') that could account for this abnormal behavior. This lockup occurs with or without the split tunnel.
I should also point out that the "initializing Java tooling" progress status ALWAYS occurs when starting eclipse and takes about a minute to complete with VPN connection. Normal (<2 seconds) without.
So, I'm starting to learn how to use wireshark and possibly will look into using packetlogger as well in an attempt to find out more about this strange issue.
Anyone have a clue as to what might be causing this?
This is a hard one to answer. Short answer is "I don't know".
However, I did find out that, due to the recently updated JVM, done as part of the Mac OS X update, Eclipse IDE lost its ability to find the src.jar file for the JRE. As a result, it appears that Eclipse, in various places in the code, searched for this file and when not found attempted to find it via the network. When VPN was turned on, perhaps this exacerbated the problem.
This was solved by fixing the Installed JRE configuration of Eclipse (see JDK on OSX 10.7 Lion).