Run .NET desktop app on Creepy windows

Run .NET desktop app on Creepy windows

ยท

2 min read

Play this article

The moment you run the project to the customer's computer is an uneasy timespan. There is no time to find a bug. All things should be perfect. However, things usually do not go the best way, and you see some red lights.

I developed software with .NET 6 for a company. They said I should go and install it on their systems, so I generated a setup and set the deployment mode on publish settings to Self-contained. Everything should be okay; I install a setup installer and get my bill after that. However, their system windows were a doom. Because It was a windows 7 with no updates after the first release, I will show you the errors that doomed me in this post and how I solved them.

The program can't start because api-ms-win-crt-string-l1-1-0.dll is missing.

This error was my first and most shocking. Because I checked on other computers, and I checked the produce single file setting on the publish settings, so I should not have any problems with missing DLLs. I found out this system missed one update with the name KB2999226(to find more detail about it, check this link). You can find and install this update on this link, and the error will fix.

System.TypeInitializationException: The type initializer for 'System.DateTime' threw an exception.

Application: ***
CoreCLR Version: 6.0.1122.52304
.NET Version: 6.0.11
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for 'System.DateTime' threw an exception.
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'handle')
   at System.Runtime.InteropServices.NativeLibrary.GetExport(IntPtr handle, String name)
   at System.DateTime.GetGetSystemTimeAsFileTimeFnPtr()
   at System.DateTime..cctor()
   --- End of inner exception stack trace ---
   at System.DateTime.get_UtcNow()
   at System.DateTime.get_Now()
   at System.Windows.Forms.DateTimePicker..ctor()
   at ***
...

After the last error was fixed, I thought everything was okay and It was time to get my bill๐Ÿ˜๐Ÿ˜๐Ÿ˜. But this error showed out.

This error was confusing because I had thought my code had bugs, and I got a big bug. However, when I searched, I found this bug is impossible, so I must think of other possibilities. I found out this computer missed two updates too.

These updates are required to run the .NET 6 app on windows, but Microsoft does not highlight these updates. these updates on windows 7 are Microsoft Visual C++ 2015-2019 Redistributable and KB3063858 .you can find and download these updates on this page.

To sum up, My goal is to help you! If you are still unsure of what to do or if you got any errors, I suggest you use the comment section below and let me know! I'm here to help.

ย