Author: Dave Fancher

Dave Fancher is a Software Engineer at Performance Assessment Network in Carmel, Indiana, a Microsoft MVP for Visual F#, and author of The Book of F# from No Starch Press. He has been building software with the .NET Framework since version 1.1. Dave is active within the Indiana software development community as a member of IndySA, a speaker at user groups throughout the state, and a two-time contributor to Indy GiveCamp. When not writing code he enjoys spending time with his family, watching movies, photography, and gaming on on his Xbox One.

Creating a Generative Type Provider

In my recently released Pluralsight course, Building F# Type Providers, I show how to build a type provider that uses erased types. To keep things simple I opted to not include any discussion of generative type providers beyond explaining the difference between type erasure and type generation. I thought I might get some negative feedback regarding that decision but I still believe it was the right decision for the course. That said, while the feedback I’ve received has been quite positive, especially for my first course, I have indeed heard from a few people that they would have liked to see generated types included as well.

There are a number of existing type providers that use generated types, most notably in my opinion is the SqlEnumProvider from FSharp.Data.SqlClient. That particular type provider generates CLI-enum or enum-like types which represent key/value pairs stored in the source database.

Although SqlEnumProvider is a great example and is relatively easy to follow, general how-to documentation for generative type providers is hard to come by to say the least. As such I thought that showing how to write the ID3Provider built in the course as a generative type provider would be a nice addendum for the course material. I clearly won’t be covering everything I do in the course here so if you’re looking for a deeper understanding of type providers I strongly encourage you to watch it before reading this article. (more…)

Kansas City, Here I Come!

It’s hard to believe that KCDC is next week in Kansas City, MO! I’m excited to be giving two talks.

On Thursday you can see F# Type Providers in Action which is an abridged version of my new Pluralsight course, Building F# Type Providers. On Friday I’ll break from the technical conference norm with a lighthearted look at some of my experiences from my trip into the book publishing world while I wrote The Book of F#.

Please check the schedule for updated rooms and times.

As a bonus, I hope to have a few copies of The Book of F# to give away during my sessions! I’ll be giving away a copy of The Book of F# during each of my sessions! I hope to see you there!

Building F# Type Providers on Pluralsight!

I was wrapping up The Book of F# and discussing the foreword with Bryan Hunter, he asked if I’d like to be connected to some of the folks at Pluralsight to discuss the possibility of an F# course. I agreed and a few days later I was on the phone brainstorming course ideas with them.

Of everything we discussed I was really only excited about a few topics enough to think I could put together a full course for them. Naturally the ones I was most excited about were already spoken for so I started trying to think of some other ideas. At that point I sort of fizzled out from seemingly endless distractions like changing jobs, speaking at a variety of events, and so on. Over the course of a few months I’d pretty much forgotten about the discussions. Fortunately for me, Pluralsight hadn’t forgotten and my acquisitions editor emailed me to see what happened.

We soon started talking again and one of the ideas I was originally excited about was now available and I’d been working on a related conference talk so I had the start of an outline. After a few iterations I was ready to start recording my Building F# Type Providers course.

Fast forward to earlier this week when I noticed some blog traffic from an unexpected source – my Pluralsight author profile page! I quickly discovered that my course was live!


If you’re wanting to learn more about one of F#’s most interesting features, I invite you to watch the course where I show a few existing type providers in action before walking through creating a simple type provider for reading the ID3 tag from an MP3 file using the Type Provider Starter Pack.

Functional C#: Fluent Interfaces and Functional Method Chaining

This is adapted from a talk I’ve been refining a bit. I’m pretty happy with it overall but please let me know what you think in the comments.

I’ve been developing software professionally for 15 years or so. Like many of today’s enterprise developers much of my career has been spent with object-oriented languages but when I discovered functional programming a few years ago it changed the way I think about code at the most fundamental levels. As such I no longer think about problems in terms of object hierarchies, encapsulation, or and associated behavior. Instead I think in terms of independent functions and the data upon which they operate in order to produce the desired result. (more…)

FileZilla Server and Windows Azure

I was setting up a new virtual machine in Windows Azure today and wanted to host an FTP server. Having spent most of my career isolated inside corporate environments and largely disconnected from server administration this was fairly new ground for me.

I knew going into it that I was going to have to tweak some firewall rules and whatnot but establishing communication was a bit more involved than I initially expected.

The FTP solution I selected was FileZilla Server. It’s a rather robust solution that provides the security I wanted with minimal configuration. Getting the server components installed was effortless as was creating the security groups and users. Once I had everything configured the way I wanted I created the rules to allow traffic to hit ports 21 and 990 on the server through the Windows Firewall with Advanced Security control panel.

For my first test I simply tried to FTP to localhost on the server itself. Both accounts I’d configured worked perfectly. Then, to test the firewall rules I tried to connect from my development workstation but was unable to connect.

After scratching my head for a bit I remembered seeing endpoint configuration in the Azure portal. I added two endpoints, one for port 25 and one for port 990 and was then able to connect but the FTP client kept failing to retrieve a directory list. The log showed that the client was attempting to use passive mode which requires additional ports. I quickly found the passive mode settings in the FileZilla server options. From there I was able to specify a custom range which I could then allow to pass through the firewall. The other thing I needed to change was the IPv4 specific setting to force the server to use the server’s public virtual IP address as listed on the VM’s dashboard in the Azure Portal.

FileZilla Passive Mode Settings

FileZilla Passive Mode Settings

Just as before, simply adding the firewall rules wasn’t enough to allow communication. I had to add the passive mode ports as endpoints as well. I initially found this to be more than a bit tedious but fortunately the Add-AzureEndpoint PowerShell cmdlet eased some of the pain.

Azure FTP Endpoints

Azure FTP Endpoints

Once all the rules and endpoints were in place I was able to successfully connect from my development workstation to the server and get directory listings.


Receiving Webhooks With IIS Express

One of the projects I’m currently working on is using a service that reports various events back to our system via webhooks. Since the features I’m working on aren’t ready for deployment yet I was looking for a decent way to test the integration in my development environment to ensure that I’m not only receiving the correct data but also that I’m handling it properly.

The service’s documentation recommended pointing the webhooks to another service such as RequestBin to inspect the contents. I did mess around with that approach for a bit and although I was certainly able to see the requests in the RequestBin log and push them on to the application with fiddler, it really didn’t seem like an adequate solution and I was tired so I went to bed.

It turns out that sleeping on it was exactly what I needed. Sometime overnight I subconsciously worked out a better solution; I could open up IIS Express to handle remote connections and configure NAT on my router to forward requests for that port directly to the IIS Express instance. It turns out that getting all this working was actually quite simple.

Allowing Remote Connections

Allowing remote connections to IIS Express requires a little work but it’s pretty straight-forward and is outlined in this stackoverflow post. In short we need to:

  1. Create an additional IP binding for the IIS Express site to allow traffic from all hosts.
  2. Allow connections to the port from anyone
  3. Create a firewall rule to allow traffic to the port on the development machine

Creating an IIS Express Binding

IIS Express sites are managed per-user. To create the IIS Express binding we simply need to create a new entry for the site in the configuration file located at %userprofile%\documents\iisexpress\config\applicationhost.config. In the file locate the site then duplicate the binding, changing the allowed host to *. For example, if the current binding is:

I’ve used port 99999 in these examples for demonstration purposes only. You’ll want to use the port listed in your configuration file.

<binding protocol="http" bindingInformation="*:99999:localhost" />

You’d create a copy and change localhost to * such that it reads like this:

<binding protocol="http" bindingInformation="*:99999:*" />

It’s very important that you leave the original binding in place. Yes, it is redundant to have a binding for all hosts and another for only localhost but Visual Studio uses the localhost binding to initialize IIS Express. If that binding isn’t present Visual Studio will create a duplicate site entry and you’ll likely start seeing errors such as the one pictured below.

URL Binding Failure

URL Binding Failure

Setting Security on the Port

Once you’ve created the IIS Express binding you need to allow connections to the port. This is done by executing target=”_blank”>netsh to add a URL reservation for the new binding. In this case we’ll be using netsh http add urlacl to register the address we bound to the IIS Express site and granting permission to everyone.

netsh http add urlacl url=http://*:99999/ user=everyone

Note that “everyone” refers to the Everyone group in Windows. If you’re using a non-English version you’ll need to change that to the localized name for your language.

Creating a Firewall Rule

The final step is allowing traffic to that port through the local firewall. Accomplishing this varies according to which firewall solution you’re using. For Windows firewall you can control this through the control panel or by executing the following netsh command which changes some advanced firewall configuration settings.

netsh advfirewall firewall add rule name=”IISExpressWeb” dir=in protocol=tcp localport=99999 profile=private remoteip=any action=allow

Configuring NAT

Configuring NAT is not something I can really help with in this article because each environment will have its own instructions and restrictions. For me and my home office network it was easy because I simply had to add a custom application that referenced the configured port and host machine in my router’s firewall configuration.

Alternatively, I could have configured the IP Passthrough to route traffic to the development machine but I deemed this to be too much exposure to the outside world and left it with NAT.

Accepting Webhooks

Once I’d configured everything on my network to accept the webhook traffic I went to the external application’s dashboard and registered my computer as a webhook recipient using the WLAN IP address I obtained from my router’s status page and the port I bound to IIS Express for the application. I then set a breakpoint in the webhook processing logic, ran the application, made a change in the remote system to initiate sending an event, then watched in amazement as my breakpoint was hit and the watch window showed data received from the remote service.

Mission accomplished.

Setting up a Home Recording Studio

I’ve been preparing to do some audio recording in my home but getting started has not been without its share of challenges. Having a rambunctious 5 year-old certainly limits the times when I can record without interruption but that’s certainly manageable. The biggest problem I’ve been facing is the house itself.

My house sucks for recording. It is an echo chamber; a cavernous open floor plan of approximately 2000 square feet where only its three bedrooms are isolated from the rest of the house. To say that the house was not designed with audio recording in mind is a fact akin to stating that the sky is blue or that water is wet. The front door opens into a foyer which is connected to my daughter’s play room and the living room. In addition to the walkway, the play room has a giant window that connects it directly to the living room. The living room is an open space that connects to the dining area and kitchen and flows upward into the loft on the second floor. The only effective spaces  for recording in the house are the three bedrooms upstairs which are connected to a central hallway. Given that two of the bedrooms are allocated for use as actual bedrooms and the third serves dual purpose as a guest room and my wife’s craft room, that leaves me the worst possible place in the house to record: the loft.

My wife and I have discussed some renovations that would isolate the loft, giving me a man cave of sorts. Isolating the loft would certainly help with many of the problems I’m trying to solve but unfortunately it’s not in the budget right now. I needed to seek an alternate solution that didn’t involve hiding in the master closet.

I started by purchasing some studio foam panels from Auralex. Not only were their panels highly recommended but I’d recently learned that Auralex is based just a few miles from my house so I’d be supporting a local business. I went with the D36-DST Roominator kit which includes 36 12 inch by 12 inch panels. I attached the panels to the walls immediately around my desk and the ceiling directly above my chair.

The Auralex panels seem to do a great job absorbing the sound as long as I was right next to them. I’ve definitely noticed their effect but given the house’s horrible acoustics they weren’t enough to eliminate the echo. I still needed to isolate the loft somehow.

My always creative wife suggested somehow mounting some curtains across the room. We toyed with a few ideas but wanted to keep the project as inexpensive as possible. Given that the loft is approximately 15 feet across and the ceiling is approximately 9 feet high we were going to need quite a bit of fabric. We also needed to determine how to hang the fabric,. We first thought about a tension rod or mounting a curtain rod from the ceiling but then she found this post on Apartment Therapy which seemed like it might do the trick.

Because I wanted the curtains to help reduce the echo we decided to get some velvet from Jo-Ann’s instead of the lighter sheets mentioned in the Apartment Therapy article. Beyond that, we took pretty much the same approach, adjusting a bit for strength mostly to alleviate my fear that the velvet’s weight would pull one (or both) of the eye hooks out of the wall.

Curtain Materials:

The project cost around $250.00 in materials between the Auralex panels and the curtain supplies. Excluded from that total are the cable cutters I had to purchase because I didn’t have anything capable of cutting the wire rope, and the tape we used to try hemming the velvet (epic failure on that one).

Over the course of the project I learned a few things.

  1. Wire rope is really hard to cut.
  2. Cheap velvet doesn’t help as much as we’d hoped.
  3. I should never work with fabric. We tried using some fabric tape to hem the velvet but that was a colossal failure. My wife ended up hand-sewing the velvet after the cloth got stuck in the sewing machine.
  4. I should get some real curtains to cover the window. It currently has wood blinds but I still get a lot of noise from the road.
  5. I should probably get a few more Auralex panels.

Since completing the project I’ve recorded and submitted a production sample video and it seems to have passed all of the initial quality gates so overall I’m quite happy with the result. I do still notice some echo on the recording but it’s markedly better than it was before hanging the panels and curtains. Even sitting here, writing this with the curtains closed I notice an improvement in the acoustics. I do still need to remember to shut off the furnace before recording (and turn it back on when I’m done – oops) but that’s a minor inconvenience compared to being sequestered to a closet.

I realize this configuration is far from ideal so if you have any suggestions for how I could improve it I’d love to hear them!