Launching .EXE applications from a browser

My client has an Angular intranet portal for their main c# WinForm application. They have a requirement to launch the main application from the portal website.

There is a fairly easy way to go about this in Windows although it does require adding an entry to the registry, to set up a URI Scheme. Here is an example to load notepad.exe

HKEY_CLASSES_ROOT
   jmNotepad
      (Default) = "URL:jmNotepad Protocol"
      URL Protocol = ""
      DefaultIcon
         (Default) = "notepad.exe,1"
      shell
         open
            command
               (Default) = "C:\windows\notepad.exe"

In the web page, add a simple link:

<a href="jmNotepad:">Launch Notepad</a>

The first time it’s launched you get a warning, which you can click to ignore subsequently.

Advertisements

Trouble with Keys

I’ve just spent a couple of hours scratching my head with database/entity framework problem.

My client has a requirement to duplicate records from one database to another when the first is updated.

The tables were identical and based on a class inherited from the IdentityUserRole class, with another field added to the composite key.  However, although data saved OK into the original database, an error was being thrown when trying to duplicate the records into the second database.

After some debugging, I found out that it was an issue with the primary key. It wasn’t recognising the composite key.

The quick fix was to add the following into the dbContext class, in the OnModelCreating method:

modelBuilder.Entity<ApplicationUserTeamRole>().ToTable("AspNetUserRoles")
 .HasKey(x=>new{x.RoleId,x.UserId, x.TeamId});

Everything immediately started working.