Previous part is here.

Configuring Web Server

I chose nginx as web server because after research it looks like it is gaining a lot of popularity while second contender Apache2 is losing popularity.

First step is to ensure that your web server is working correctly. Because http port is opened in Amazon router and in your virtual PC you should be able to access it from outside from your browser. Just type https://<you static IP address> in your browser and press Enter. You should see standard nginx web page.

Next step is to make sure that nginx will not serve anything that is not specifically added. Edit file /etc/nginx/sites-available/default and replace it content with following:

server {
	listen 80 default_server;
	listen [::]:80 default_server;
	return   444;
}

Some time ago I needed simple tutorial site. Initially I was thinking about static page hosting and I started research. But during research I found AWS Lightsail service. It cost $3.5 per month and offers 1 vCPU, 512 MB of RAM, 20 GB of SSD space and 1 TB of data transfer. It is about that the same as my current hosting offers but in case of Amazon it is your own virtual PC, and you can do whatever you like there. It looks attractive, but there is one catch. It is Linux. I had some experience with Linux, but it was far from extensive. On another side I really like challenges, so I decided to try it.

But before

  •   Posted in:
  • .NET

Recently I got relatively simple deadlock case, but I found quite interesting things during investigation. Our application hangs when user tries to quit it. I got dump file for this case and started investigation.

Call stack for main thread looks like this:

...
clr!JITutil_MonContention+0x115
System_ni!System.ComponentModel.Component.Dispose(Boolean)$##60031F8+0x40
System_ni!System.IO.FileSystemWatcher.Dispose(Boolean)$##600266D+0xd7
System_ni!System.IO.FileSystemWatcher.Dispose(Boolean)$##600266D+0xa6
System_ni!System.ComponentModel.Component.Dispose()$##60031F7+0x1a
...

As you clearly see, application waiting in FileSystemWatcher’s  System.ComponentModel.Component.Dispose. If you go to https://sourceof.net and paste name of the method there to see source code, you will see that there is lock(this) and it looks like some other thread obtained lock before us. Obviously, I went over other 168 threads and found 2 similar call stacks. First thread was executing event from first

Case of frozen File Explorer

Some time ago I started to get strange freezes when I try to open File Explorer. New File Explorer appears on screen, renders left and top part and then displays “Working on it…” where files supposed to be and then nothing. And today I would like to share my discoveries.

Obviously, first thing I tried to kill File Explorer and start over. Exactly the same behavior. I rarely use File Explorer because I prefer FAR file manager. But sometimes I do use File Explorer, mostly to copy files via Remote Desktop. In this particular case I decided to start FAR file manager to check something. And to my surprise, exactly the same happens to FAR.

Recently one person asked me to check following code:

1. if (s.Length > 1)
2. {
3.     string numberString = s.Substring(0, 1);
4.     result.Text = s.Substring(pos + 1, s.Length - pos);
5. }

When that person runs this code, it throws ArgumentOutOfRangeException exception on line #3. But as you can see, first line checks that string is not empty and s.Substring(0, 1) should never throw any exception. And looks like that person was correct.

Then I found that this code compiled for .NET Core 3.1. I tried to increase version to .NET 5 and problem is still there. I put breakpoint to line 3 and run application. When application stopped on that line, I

Recently I got strange situation in our application. We have two different classes in .NET that exposed to managed code via COM interfaces. Both classes look very similar but one class by some reason supports IDispatch while another class does not. We have piece of code that work quite differently depending on IDispatch support. And was asked to investigate what is going on and why these two classes behave different.

Here is some data. First class looks like this:

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class Foo : BaseClass1, IDisposable

Second class looks like this:

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class Bar : BaseClass2, IMyInterface

IMyInterface declared like this:

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("XXX")]

If

I am happy owner of iPhone from iPhone 4. I never had any issue with them. All issues were some kind of my fault. But one thing is really annoying me modern iPhones – charge cables. I do not remember what year it started, but at one moment I did realize that plastic that protect lightning cable started to crack. I did not pay attention and thought that I misused it. So, I just used tape to isolate that place. But then it cracked in different place and in another place. I went I bought another cable. And year later perfectly working cable started to crack again. Cable was still working fine, just looks ugly and all wires are stripped.

Probably everyone who wants to follow recent trends in hardware is usually watching some news over that subject and views some reviews for new hardware. For most hardware reviews I usually watching Hardware Unboxed channel. While many other youtubers provide the same content, but I really like their style, they way of presenting, data they provided etc. Plus following them for quite some time I never seen any leaning towards any side. They are always on the truth side.

And today I seen this video: Nvidia Bans Hardware Unboxed, Then Backpedals: Our Thoughts - YouTube. Basically, if you do not have time to watch, NVIDIA sent email to Hardware Unboxed saying that do not pay enough attention (and do

I would like to buy NVIDIA 1600 Ti video card. Normally it did const around $260, and I was expecting that on Black Friday there will be good discounts. To be honest I was wrong. Most sites like New Egg had Black Friday week and they guarantee that if prices will be lower ever in November than they will automatically credit difference.

Anyway, today I did check and pretty much everything is sold out. And then I found idepothome.com where this video card cost $160.00. It immediately raised my suspicion. This video card normally cost around $300. Why would anyone make discount at least $140 when your competitors are simply out of stock? It is way simpler to drop $50