Checking whether a DLL is 32-bit or 64-bit

A very easy method to check whether a particular DLL is x86-64 compatible or not is by using the file command in Linux. If you have bash installed on your Windows, you can type:

file MY_DLL.dll

If it’s a 64-bit DLL, you will see:

PE32+ executable (DLL) (GUI) x86-64, for MS Windows

Otherwise, it prints:

PE32 executable (DLL) (GUI) Intel 80386, for MS Windows

Resetting Windows 10 bash user password

If you have forgotten your bash user password on Windows 10, there is a way to log in as root to reset that user’s password using passwd.

First, make sure all bash windows are closed. This is important as if one bash instance is open, this may not work:

  1. Open a Command Prompt as Administrator. You can do that by typing cmd in the Start menu and pressing CTRL+Shift+Enter.
  2. Run: ubuntu config --default-user root
  3. The previous command tells bash to log in as root the next time it’s started. So you can now run a rooted bash by typing bash.
  4. Now you can reset any user’s password by entering passwd myuser
  5. Finally, exit bash, and in the elevated Command Prompt, type ubuntu config --default-user myuser to change the default bash login to your bash user.

Solving “Native linking failed” issues running Xamarin.iOS on Simulator

Some external libraries will cause the project fail to build on the iPhoneSimulator (e.g. x86_64) target. The resulting errors can be:

Native linking failed. Please review the build log.
Native linking error: 1 duplicate symbol for architecture x86_64
Duplicate symbol in: /Users/admin/Library/Caches/Xamarin/mtbs/builds/.../obj/iPhoneSimulator/Debug/mtouch-cache/x86_64/main.o (Location related to previous error)
Duplicate symbol in: /Users/admin/Library/Caches/Xamarin/mtbs/builds/.../obj/iPhoneSimulator/Debug/mtouch-cache/leveldb-library(leveldb_main.o) (Location related to previous error)
Native linking failed, duplicate symbol: '_main'.

Sometimes you can make the build work by adding --registrar:static in the Additional mtouch arguments (MtouchExtraArgs) setting of the iOS project properties.

EF / SQL Server writes too slow?

I was using Entity Framework Core on a project which required a large amount of writes (inserts and updates) to a SQL Server 2017 database. The operation was extremely slow, in the order of several hours/half a day. I figured out that it was due to the EF overhead for tracking changes. Setting the following boolean to false saves a lot of time, if you have to do a lot of writes:

using (var db = new MyContext())
db.ChangeTracker.AutoDetectChangesEnabled = false;
//Do Stuff
db.ChangeTracker.AutoDetectChangesEnabled = true;

Fixing Doom3 BFG Edition on multi-display setups

I have a triple display setup with two 1080p monitors and a third 4:3 one, and I had some free time to kill, so I decided to give Doom3 BFG edition a try. The problem is that, for me it started full screen in a display that I didn’t want to play on, and in a screwed up resolution. As there are no helpful options in the settings menu, it was tricky to solve this issue, but finally I managed to fix it. So if you have this problem, here is the way to solve it:

  1. Open the D3BFGConfig.cfg located in your user’s home folderSaved Gamesid SoftwareDOOM 3 BFGbase in a text editor.
  2. Look for the line r_fullscreen. It is initially set to 1. By changing it to 2 or 3, you are able to move the game to different displays.
  3. Now to fix the resolution, first change r_vidMode to –1, and then set the values of r_customHeight and r_customWidth to your desired resolution. In my case the settings are:

    set r_customHeight “1080”
    set r_customWidth “1920”
    set r_fullscreen “2”
    set r_vidMode “-1”