“Could not load file or assembly FSharp.Core, Version=” In An ASP.NET Application

If you’ve ever tried to use an F# class library from an ASP.NET application, you may find that although things work perfectly when you are running locally, your web app won’t load at all in production.

Could not load file or assembly ‘FSharp.Core, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.

Fortunately, the fix is easy. All you need to do is add a reference to FSharp.Core to your web project, and set its Copy Local property to True. Not familiar with how to do that? Here’s a quick overview.

First, go to the Solution Explorer and right-click on your web project, or on your web project’s References folder, and select Add Reference…


In the Reference Manager window, select Assemblies, and the find the FSharp.Core, version 4.3 reference. Check it, and click OK.



Finally, in the Solution Explorer, find the FSharp.Core reference in your project’s References folder. Select it, then open the Properties window (or tab, or pane, depending on how you have Visual Studio configured), and set Copy Local to True.


That’s it! Deploy your web app to your server, and the error will be gone.

JavaScript string literals and </script> tags don’t mix

What do you think happens if you try to open up a web page containing the following HTML and JavaScript? Give it a try – the results may surprise you!


It turns out that web browsers are very indiscriminate when parsing closing script tags. The browser will find the </script> tag, even though it’s inside of a string literal in a <script> tag, and consider it to be the end of the script. The result is a few leftover characters and an unmatched </script> tag, which the browser chokes on.


Chrome throws an “Uncaught SyntaxError: Unexpected token ILLEGAL” error.

This was definitely not theĀ behaviorĀ I was expecting. After thinking about it, though, it makes perfect sense. The HTML parser doesn’t know anything about the contents of the script. It doesn’t understand that quoted strings should be treated differently. And why should it? The stuff inside the script tags could be anything, in theory.

Sure, this isn’t iOS-specific, but I thought it was interesting enough to be worth sharing anyway.