Monday 23 January 2017

Web API "could not be opened because the C# 2015 compiler could not be created"

I had a WEB API project that could not open in Visual Studio 2015. It would error with "could not be opened because the C# 2015 compiler could not be created".

In the end, the solution was to delete %AppData%\Local\Microsoft\VisualStudio\14.0\ComponentModelCache

and restart Visual Studio.

Sunday 22 January 2017

Can't access the pfSense WebConfigurator after initial configuration

If you follow this video to set up pfSense, you cannot access the WebConfigurator after installation.

This is because of two reasons:

1. The LAN is left configured as a 192.168.x.x address.
2. The firewall is turned on by default.
3. The firewall for the WAN interface blocks private networks and loopback addresses - 192.168 is one of these.

You can access the GUI initially by going into the shell and turning off the firewall with pfctl -d.
The other thing to do is to change the LAN ip address and set up the firewall to allow HTTP to this address.

The setting is:
Blocks traffic from IP addresses that are reserved for private networks per RFC 1918 (10/8, 172.16/12, 192.168/16) and unique local addresses per RFC 4193 (fc00::/7) as well as loopback addresses (127/8). This option should generally be turned on, unless this network interface resides in such a private address space, too.

So you cannot use anything starting with
10.x.x.x or
172.16.x.x or
192.168.x.x

If you change the IP address it is prudent to restart pfSense.

Ford Galaxy "Car Operative Press Stop"

For about a month we received the "Car Operative Press Stop" warning when starting the Ford Galaxy. We couldn't find any information on it. Some people suggested it was left over from when someone opened a door when the car engine was running.

In the end we found the problem. There was a loose battery terminal which was causing intermittent connections and sparking. The battery terminal nut got so hot it melted a hole in the battery cover and welded the nut onto the bolt.

The car must have been clever enough to detect this intermittent power and warned the driver to seek attention.

After the bolt was replaced and the terminal tightened, the warning went away.

Sunday 8 January 2017

Programming the ADS-FX2 solenoid controller with JMRI

It is possible to program the ADS-FX2 solenoid controller with JRMI with the following procedure:

1. Open PanelPro
2. Open Power Control (Tools > Power Control)
3. Ensure the power to the track is on
4. Open Tools > Tables > Turnouts
5. Add the IDs of the turnouts that you wish to program (Click Add, then enter the hardware address and save)
6. Open a throttle (Tools > Throttles > New Throttle)
7 Set the switch on the ADS-FX2 for the desired solenoid to Program
8. In the throttle window enter the desired address into the address panel and press Set
9. Go to the Turnouts table window and Issue the Thrown / Closed command against the matching address that you entered in the earlier step
10. Set the switch on the ADS-FX2 back to Run
11. Try throwing the points using the Turnout table window

Tuesday 3 January 2017

DocumentDB protocol support for MongoDB

DocumentDb now supports the MongoDB protocol.

I did a test before Christmas using a very slightly modified NEventStore with Mongo persistence routed to DocumentDB. Everything worked fine at the time, now after Christmas something is awry. I wrote a test to isolate the problem and it appears that when persisting a long value (with the expectation it is serialized as an Int64, it is written as an Int32).

I can't figure out what has changed. Perhaps it is my code, or has Microsoft done something "under the hood"?

I tried the code below. The two connection strings alternate between the local "real" Mongo 3.4 server and the DocumentDB with Mongo support in Azure. I added the mongocsharprdriver version 1.10.0 (the one I used before Christmas) and then the very latest and no runtime difference was found.

The code below writes the long as an Int32 in DocumentDb, but as a long in the local MongoDB.


using System;
using System.Linq;
using System.Security.Authentication;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Driver.Linq;

namespace DocumentDb.Mongo.Test
{
    internal class Program
    {
        static void Main()
        {
            const string connectionString = @"mongodb://<my Azure MongoDB DocumentDB connection>/?ssl=true&sslverifycertificate=false";
            // const string connectionString = @"mongodb://localhost:27017/test";
            const string indexName = "_id";
            var clientSettings = MongoClientSettings.FromUrl(new MongoUrl(connectionString));
            clientSettings.SslSettings = new SslSettings() { EnabledSslProtocols = SslProtocols.Tls12 };
            var client = new MongoClient(clientSettings);
            var db = client.GetServer().GetDatabase("test");
            var collection = db.GetCollection("testcollection");
  
            const long testValue = 1;
            var doc = new BsonDocument
            {
                {indexName, testValue}
            };

            collection.Update(
                Query.EQ(indexName, testValue),
                Update.Replace(doc),
                UpdateFlags.Upsert);
                
            doc = collection.AsQueryable().First();
            Console.WriteLine($"Value={doc[indexName].AsInt64}");
        }
    }
}