•   Posted in:
  • .NET

The previous part is here.

And finally, we are in the most important part which explains what works differently between the .NET Framework and .NET 6. Just in case I will talk about behavioral changes and about obvious parts like some methods that do not exist in .NET 6 but I will

  1. The .NET Framework will suppress all exceptions when it releases a reference to a COM object but .NET 6 will crash. One example of such a problem is when some object is freed despite having a reference count of more than zero. It is a bug and needs to be fixed. I just was surprised by how often it happened in our application.
  2. Accessing .NET from DllMain will lead to deadlocks. We had these in the .NET Framework, but they happened much more often in the .NET 6. And obviously, it needs to be fixed. It will take some time because it works most of the time and deadlock happens quite seldom.
  3. string.GetHashCode will return different values every time you start the application. Basically during startup runtime will generate a random seed and add it to the hash code. If you want hash code to persist then write a function that hashes string differently.
  4. When the application converts a floating point number to a string, the result will be slightly different. Here blog post that explains the changes. For example, when the .NET Framework outputs 3.1415, .NET may output as 3.141500001 or 3.141499999.
  5. Encoding.Default will be always UTF8 in .NET 6. If you want to return old behavior then you need to create Encoding from the current Windows code page.
  6. System.Diagnostics.ProcessStartInfo.UseShellExecute is true for .NET Framework but false for .NET As a result, previously it was possible to open the http link without changing properties but now UseShellExecute must be set specifically to true.
  7. Previously it was possible to bind to read-only property in WPF. Now it throws an exception and you need to add “, Mode=OneWay”.
  8. SHA512.Create("System.Security.Cryptography.SHA512CryptoServiceProvider") will return null. We replaced it with new SHA512CryptoServiceProvider().
  9. There is no SHA512Cng class. We replaced it with SHA512CryptoServiceProvider class that uses SHA512Cng internally when the application is running for Windows.
  10. Setting SecurityProtocolType.Ssl3 will throw an exception.
  11. Some controls were removed from WinForms. For example ContextMenu. They were replaced with a set of different controls quite some time ago but our code used an old version for some reason.
  12. In the .NET Framework, your application can load assembly A 2.0.0.0 from the application directory. Later it can load assembly K located in a different directory and assembly K can load assembly A version 1.0.0.0 from the same directory that contains assembly K and it will work. This will fail in the .NET 6 because another version with a higher version is already loaded. To fix this you will need to use AssemblyLoadContext.
  13. If you are using different assembly versions in WPF then it will work properly. You will have to rename assemblies to include the version in the assembly name. I spent quite a bit of time on this and I didn’t find any better way.
  14. If you are enumerating over HashSet sometimes it will contain elements in a different order in .NET 6. We found that during tests. But HashSet does not guarantee the order so it was an issue on our side.
  15. string.Compare("C-O", "CA") will return 1 for the .NET Framework and -1 for .NET 6. It is because Microsoft changed how comparing works to have the same result for all platforms. Previously it used Windows API for this.

The previous part is here.

As I wrote before our project has 824 C# projects. As you can imagine it is a lot of source code and converting so much code will take quite a lot of time. But we typically release a new version of our product every month and we definitely will not be able to finish all converting and testing within one month.

As a result, we have to create a branch and periodically merge changes from the main/master branch. But there are the following problems:

  • csproj file is for .NET 6 is very different from csproj file for the .NET Framework
  • if we change some code and this code will be changed for the .NET Framework then we will have to do tricky merges
  • it is a lot of work to convert many projects and we expect that some projects need manual conversion
  • build system needs to be changed as well to be able to build the .NET Core projects

Our company has a relatively big desktop product that still uses the .NET Framework. We tried to switch to .NET 5 in 2020 but we had one dependency that we could not make to work for the .NET Core family because it used things that were considered legacy even for .NET Framework. But this time it was way more successful and this is a story about how we were switching from .NET Framework to .NET 6 and what issues we had on our way.

But before you do anything you need to know why are you doing it. This is a really important question because such a huge change will create a lot of regression and your clients will be

I’m sure that many of you heard about a backdoor in xz util that allows specific people to get root access if Linux is configured to allow incoming SSH connections. There are a lot of systems like that because it is a typical configuration for pretty much every Linux machine. Fortunately, it was caught quickly, and as far as we know there were no real hacks made via that backdoor.

But it reveals a lot of problems and most of them are typical for open-source development.  I would like to review them and to explore if these problems apply to the closed-source world.

Let’s start with the obvious problem. You rarely get paid for developing open-source projects. Most of

Recently I found that IPv4 for Lighsail will cost more from the 1st of May. And I decided to switch my test site to IPv6 only. I followed the guide that states that I had to create a snapshot and then restore it to an IPv6-only instance. Then I decided to connect to it via SSH and check that everything works fine.

To my surprise, I cannot connect to it. I tried everything and nothing worked. Then I tried to ping it and it also did not work. To make a story short eventually, I found that the issue was in my main OpenWrt router.

And then I remembered that I did something special in old versions of OpenWrt

Some time ago I wrote a series of posts about the Amazon Lightsail product. I really like Lightsail for simplicity and because for $3.5 I can create a fully functional virtual PC with a static IPv4 address. This way I can add an A record in my DNS server and point you to this virtual PC.

But recently Amazon changed conditions and IPv4 is not free anymore. By default, it will cost $1.5 per month. It is not a big deal by itself but it effectively increases the price from $3.5 to $5 which is more than a 40% increase. Previously it was impossible to compete with Lighsail, but for $5 there are way more offers.

Today I installed an update to my Tesla that allows me to test Full Self Driving (FSD). And it is just amazing what it can do. The car practically drove me to work and back. But there are quite a lot of things that make my blood pressure rise.

The first thing was relatively minor. The car did a left turn and stayed in the leftmost lane. And for some reason maintains a speed 5 miles below the limit for quite some time. I had to manually accelerate it. And once or twice the car went over lane markings. There were no cars in the adjusted lane so it was not a big problem.

The next was not as good.

Currently, Tesla is selling a Full Self Dring (FSD) package for $12 000. Previously it was $15 000 but it was just insane. And recently Tesla sent an email to customers in the US to let them know that they can test it for a whole month for free. Obviously, they want to sell more of it, but I cannot quite understand who is supposed to be the intended audience for such a product.

Any Tesla can keep the lane and have adaptive cruise control and it works very well. Well, almost well until there is phantom braking but it does not happen often. These 2 things may not look like much but on long trips, it is what helps

Like many other people, I am watching YouTube. And as everybody knows, in YouTube videos, you can see Google Ads and very often, creators promote some product or brand. And recently I saw quite a lot of promotions for VPN services.

And many such VPN ads promote the VPN as a means to protect your privacy and data. But it actually doesn’t do any of that. Well, to be 100% honest VPN can protect your privacy, but not for the average person because it requires strict discipline. But it 100% cannot protect your data.

VPN is short for Virtual Private Network. A typical use for VPN is a means to connect to your work environment from your home computer. Instead