2020-08-27 Learned Today


How to use the PlayStation 4 – Dual Shock 4 controller on a Windows 10 laptop by using the built-in default Bluetooth receiver with Fortnite

The battle between Apple and Epic games let too my kids not being able to play the last Fortnite season on their Apple (iOS) devices.

They decided they wanted to play the new Fortnite season on a good old Windows 10 laptop, but just like on the Apple (iOS) devices, they wanted to use a PlayStation 4 – Dual Shock 4 controller.

Out of the box I could connect the controller just by pressing the Press the “PlayStation” button and the “Share” button on the controller at the same time and hold them down.

Just make sure you are not in reach of a PlayStation.



But after that the controller was connected to the Windows 10 laptop, but Fortnite did not recognize the controller.

After a short search on the internet I found the solution at: http://ds4windows.com/

I downloaded this software / driver from Github and installed it.

After rebooting and connecting the PlayStation – Dual Shock 4 controller, before starting the Fortnite game.

Fortnite recognized the controller and all was well .

My kids now use a Windows 10 laptop for playing the last Fornite season.

Data flows and good DDD architecture in .NET Core and Entity Framework (EF)


    # Introduction

From the blog post at https://medium.com/@jpdeffo/domain-driven-design-ddd-in-microservice-architecture-for-nutshell-19c7c579009a and code at https://github.com/Defcoq/DDD 

I have learned how to architect a .NET Core project by using DDD principals.

The main thing you will have to realize, when you come from a layered architecture, is that the logical flow of data, does not correspond with the project references in Visual Studio.



    # Logical dataflow

    Controllers (MyApp.Web.csproj) => Domain Services (MyApp.Domain.csproj) => Persistence services (MyApp.Persistence.csproj)


    Controller data flows

    – On a HTTP GET a .NET controller will,

      OPTIONAL – Receive primitive types or data transfer objects (DTO) from the client

      OPTIONAL – Map data transfer objects (DTO) to domain models

      Call domain service(s) by using DI

      Receive domain models

      Map domain models to data transfer objects (DTO)

      Return data transfer objects (DTO) to the client.

    – On a HTTP POST a .NET controller will,

      OPTIONAL – Receive primitive types or data transfer objects (DTO) from the client

      OPTIONAL – Map data transfer objects (DTO) to domain models

      Call domain service(s) by using DI

      OPTIONAL – Receive domain models

      OPTIONAL – Map domain models to data transfer objects (DTO)

      OPTIONAL – Return data transfer objects (DTO) to the client.


    Domain Service data flows

    – Receive primitive types or domain models

    – Act on domain models

    – OPTIONAL – Call persistence services with primitive types or domain models, by using DI

    – OPTIONAL – Receive primitive types or domain models

    – OPTIONAL – Return primitive types or domain models


    Persistence services data flows

    – OPTIONAL – Receive primitive types or domain models

    – OPTIONAL – Map primitive types or domain models to persistence models

    – OPTIONAL – Act on persistence models

    – Call an ORM or other persistence layer framework

    – OPTIONAL – Map persistence models to primitive types or domain models

    – OPTIONAL – Return primitive types or domain models




    # Project references

    Controllers (MyApp.Web.csproj) => Persistence services (MyApp.Persistence.csproj) => Domain Services (MyApp.Domain.csproj) => MyApp.Infrastructure.csproj (Logging, Monitoring, Security, and other code that can be reused between projects).


    By putting the Interfaces for the ‘persistence services’ inside the ‘domain’ project, the implementation inside the ‘persistence’ project and referencing the ‘domain’ project from the ‘persistence’ project and using DI inside the ‘web’ project sta.

    We can make the ‘domain’ project totaly independent from other custom assemblies and make the controllers only use types from the ‘domain’ project.

    Note: All data coming from the ‘persistence’ project and all data send to the ‘persistence’ project, should be primitive types or ‘domain’ models.

    It is a good practice to make the Entity Framework types internal, so they cannot be accidentaly used outside the MyApp.Persistence.dll.

    In some cases, you will have multiple persistence projects, e.g. when you must interact with a database and other micro services.

    – MyApp.Persistence.Database.csproj

    – MyApp.Persistence.MyOtherMicroService.csproj




    # Other Resources

    A good description of passing data between layers and how you should do that, is described here:



    EF and DDD



p style=”background: #1e1e1e”>

2020-08-13 Learned Today


How to correctly add a foreign key in sql server

When you script a table that has a foreign key, SQL Server Management studio will generate the following code:



ALTER TABLE [Production].[ProductCostHistory] WITH CHECK ADD

CONSTRAINT [FK_ProductCostHistory_Product_ProductID] FOREIGN KEY([ProductID])

REFERENCES [Production].[Product] ([ProductID])


followed immediately by :


ALTER TABLE [Production].[ProductCostHistory] CHECK CONSTRAINT




Why the the last 3 lines?

The last 3 lines enable an existing foreign key, but does not check if the data in the table is consistent with the foreign key.

If you want to do that you would have to write:





Yes, this seems strange “CHECK CHECK”, but this is how the documentation states it should be written:



I think the lines are generated for safety (sometimes foreign keys are disabled en not enabled again, this will cause the query optimizer to not use these untrusted foreign keys), but I think this should be done in a monitoring scripts not in a deployment script for a new version of the database.


Will dropping a table remove constraints in SQL Server?

When you drop a table in SQL Server, all primary keys, foreign keys, defaults etc are removed from the database.


2020-08-10 Learned Today


How to fix: Apple CarPlay not working in a Peugeot e-208 with iPhone XS Max

Apple CarPlay was working fine with an iPhone 7 and an iPhone 8, but when I wanted to use Apple CarPlay in a Peugeot e-208 with an iPhone XS max, it would connect as a “ipod”, but CarPlay was not working.

To fix the problem I had to enable Siri, after enabling Siri on my iPhone XS max, Apple CarPlay started to work.

I don’t like to use Siri, but I really like to use Apple CarPlay, so I decided to enable Siri for now.

2020-07-17 Learned Today


How to fix .NET C# error: System.Security.AccessControl.PrivilegeNotHeldException: The process does not possess the ‘SeSecurityPrivilege’ privilege which is required for this operation.


If encountered the error “System.Security.AccessControl.PrivilegeNotHeldException: The process does not possess the ‘SeSecurityPrivilege’ privilege which is required for this operation.”, when calling GetAccesControl,

with “AccessControlSections.All”. After I changed this to “AccessControlSections.Access” the problem was resolved.


namespace ConsoleApp1


    class Program


        static void Main(string[] args)


            Console.WriteLine($”Start application”);


            DirectoryInfo dirInfo = Directory.CreateDirectory(\\SomeNetworkPath”);

            DirectorySecurity dirSecurity = dirInfo.GetAccessControl(AccessControlSections.Access);


            Console.WriteLine($”Wait for user to close the application”);





p style=”background: #1e1e1e”>}





2020-07-16 Learned Today


Visual Studio Code can be used as hex editor

By installing this extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode.hexeditor


How to play an entire folder containing *.mp3 files from OneDrive on iOS / iPhone

Yes, it is a paid app if you want to play an entire folder containing mp3 files from OneDrive, but it does the job well.


.NET C# FileInfo class does NOT support uri’s like file:/// or file:/

The code:

string assemblyPath = “file:///C:/Temp/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.exe”;

FileInfo assemblyPathFileInfo = new FileInfo(assemblyPath);

Will throw the error System.NotSupportedException: ‘The given path’s format is not supported.’

I encountered this problem, when I wanted to get the location of an .NET console executable, by using:



using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace ConsoleApp1


    class Program


        static void Main(string[] args)


            string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

            Console.WriteLine($”Exe is located at {nameof(assemblyPath)} [{assemblyPath}”);


            Uri assemblyPathAsUri = new Uri(assemblyPath);

            string assemblyAbsolutePath = assemblyPathAsUri.AbsolutePath;

            Console.WriteLine($”Exe is located at {nameof(assemblyAbsolutePath)} [{assemblyAbsolutePath}”);


            string assemblyFolder = Path.GetDirectoryName(assemblyAbsolutePath);

            Console.WriteLine($”Exe is located in {nameof(assemblyFolder)} [{assemblyFolder}”);







p style=”background: #1e1e1e”>



Exe is located at assemblyPath [file:///C:/Temp/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.exe

Exe is located at assemblyAbsolutePath [C:/Temp/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.exe

Exe is located in assemblyFolder [C:\Temp\ConsoleApp1\ConsoleApp1\bin\Debug



2020-07-15 Learned Today


How to open an integrated Windows PowerShell terminal / command line inside Visual Studio 2019


View > Terminal


CTRL + `


One of the great Visual Studio Code features, that was previously not supported in Visual Studio 2019, was opening a PowerShell command line inside Visual Studio 2019 itself.

Yes, there was the “Package manager console” but that behaved differently then a normal PowerShell command line.

But from Visual Studio 2019 16.3, we have an integrated PowerShell terminal inside Visual Studio 2019 itself.

2020-07-06 Learned Today


Using IIS ApplicationPoolIdentity to run git inside a PowerShell script, run by a .NET Core web application


I encountered the following error, when trying to execute a PowerShell script from a .NET Core web application:

ErrorStreamEvent: System.Management.Automation.RemoteException: Could not create directory ‘/c/WINDOWS/system32/config/systemprofile/.ssh’.

ErrorStreamEvent: System.Management.Automation.RemoteException: Host key verification failed.

ErrorStreamEvent: System.Management.Automation.RemoteException: fatal: Could not read from remote repository.


To solve this problem, I had to give the application pool identity rights on the “C:\Windows\System32\config\systemprofile” folder.

Make sure in IIS the application pool property: “Load user profile” is set to true.



What to do when “Get column information” does not work in EF 6 edmx

This is probably due to, using temp tables in your stored procedure.

Just use real tables in the stored procedure, then use “Get column information” and then remove the real tables and switch the stored procedure back to using temp tables.



What to do when EF 6 does cannot create a complex type

Sometimes, when your stored procedure ends with a select of constants for example, EF 6 edmx can’t create a complex type.

To solve this, temporarily select columns with the same type from a real table, create the complex type and revert the stored procedure back to returning constants.


Unable to start debugging on the web server. The remote server returned an error: (503) Server Unavailable.

Make sure your IIS application pool is started .





If you are developing a .NET Core web application with Visual Studio and when you start debugging your application on IIS https binding, you might get the chrome error:



I used PowerShell to create a certificate in the local Personal store on the server, then exported this certificate to a file on the server and then imported it back into the Trusted Root CAs via MMC (to avoid browser warnings).


To Create the new certificate for your specific domain:

Open Powershell ISE as admin, run the command:

New-SelfSignedCertificate -DnsName *.mydomain.com, localhost -CertStoreLocation cert:\LocalMachine\My



To trust the new certificate:

  • Open mmc.exe => Add / Remove Snap-in… => Certificates => Computer account => Local computer: (the computer this console is running on) => Finish
  • Go to Console Root => Certificates (Local Computer) => Personal
  • Select the certificate you have created, do right click => All Tasks => Export and follow the export wizard to create a .pfx file
    • Yes, export the private key
    • Check “Include all certificates in the certification path if possible”
    • Check “Export all extended properties”
    • Check “Enable certificate privacy”
    • Check “Password”
    • Use a password like “1234”
    • Encryption: “AE256-SHA256”
    • Choose a file path, like “C:\Temp\my.domain.cert.pfx”
  • Go to Console Root => Certificates => Trusted Root Certification Authorities and import the new .pfx file

To bind the certificate to your site:

  • Open IIS Manager
  • Select your site and choose Edit Site -> Bindings in the right pane
  • Add new https binding with the correct hostname and the new certificate



I had to clear the SSL state on Windows 10 before the error in Chrome was resolved





Dealing with slow “Downloading proxy settings” in Chrome


Just turn off “Automatically detect settings” in Windows 10



How to revert git commit but keep changes – aka undo last commit en redo last commit





How to fix: SQL Server – The database principal owns a schema in the database, and cannot be dropped