Enable ASP.NET 4.5 On Windows 10 or Windows 8/8.1

By default IIS and ASP.NET aren’t configured as part of a Windows setup (for obvious reasons) so developers are used to having to register IIS manually before being able to run and develop ASP.NET web sites on their desktops.  Prior to Windows 8 it was a simple command like this:

aspnet_regiis -r

This no longer works and requires a different command. Depending on what you already have enabled this may work:

dism /online /enable-feature /featurename:IIS-ASPNET45

If you haven’t enabled anything related to IIS yet you can do that at the same time with:

dism /online /enable-feature /all /featurename:IIS-ASPNET45

However!  That might not appear to solve the problem even when it has!  A post from Microsoft makes a bug apparent:

After the installation of the Microsoft .NET Framework 4.6, users may experience the following dialog box displayed in Microsoft Visual Studio when either creating new Web Site or Windows Azure project or when opening existing projects.

Configuring Web http://localhost:64886/ for ASP.NET 4.5 failed. You must manually configure this site for ASP.NET 4.5 in order for the site to run correctly. ASP.NET 4.0 has not been registered on the Web server. You need to manually configure your Web server for ASP.NET 4.0 in order for your site to run correctly.

NOTE: Microsoft .NET Framework 4.6 may also be referred to as Microsoft .NET Framework 4.5.3

This issue may impact the following Microsoft Visual Studio versions: Visual Studio 2013, Visual Studio 2012, Visual Studio 2010 SP1

Workaround:

Select “OK” when the dialog is presented. This dialog box is benign and there will be no impact to the project once the dialog box is cleared. This dialog will continue to be displayed when Web Site Project or Windows Azure Projects are created or opened until the fix has been installed on the machine.

Resolution:

Microsoft has published a fix for all impacted versions of Microsoft Visual Studio.

Visual Studio 2013 –

Visual Studio 2012

  • An update to address this issue for Microsoft Visual Studio 2012 has been published: KB3002339
  • To install this update directly from the Microsoft Download Center, here

Visual Studio 2010 SP1

  • An update to address this issue for Microsoft Visual Studio 2010 SP1 has been published: KB3002340
  • This update is available from Windows Update
    • To install this update directly from the Microsoft Download Center, here
Share

View IISEXpress Hosted Sites On Your Local Network

This is a useful little tidbit of knowledge to have.  Suppose you can browse to your new spanky site using IISExpress at http://localhost:54275/ … now you want to look at it on your phone?  Or your laptop? Or your … you get the picture …

Pre Visual Studio 2015

  1. Open up C:\Users\<yourname>\Documents\IISExpress\config\applicationhost.config
  2. Find your site definition and add in a new binding <binding protocol=”http” bindingInformation=”*:54275:<your-ip-address>” />
  3. Open Command Prompt (as admin) netsh http add urlacl url=http://<your-ip-address>:54275/ user=everyone
  4. Then execute netsh advfirewall firewall add rule name=”IISExpressWeb” dir=in protocol=tcp localport=54275 profile=private remoteip=localsubnet action=allow
  5. Then point your remote machines to http://<your-ip-address>:54275
  6. Voila!

That wasn’t so hard eh!

Visual Studio 2015

You need to complete steps 2 to 5 above, but Visual Studio 2015 by default doesn’t use the global configuration file for these IISExpress bindings.  In order to configure this you know have a couple of options.

The first option is to configure your project to use the global configuration files by added this to your *.csproj file:

<UseGlobalApplicationHostFile>True</UseGlobalApplicationHostFile>

Or you can add your addition bindings to the solution specific configuration file Visual Studio 2015 generates here:

<solution_dir>\.vs\config\applicationhost.config

Now running your solution under Visual Studio 2015 will behave as required.

Potential Errors

There are obviously too many potential errors to keep track of on a single blog post but I thought I’d detail a few fixes to issues I’ve personally experienced.

Access Denied

sometimes you may see this message when trying to launch your solution in Visual Studio.  To get around this close everything down and re-launch Visual Studio “as admin”.  This should fix the issue and then subsequent launches should work without running Visual Studio as an admin.

Failed to register URL "http://192.168.0.8:51258/" for site "<name>" application "/"
Error Description: The Network location cannot be reached.

This was a particularly annoying issue and took quite some time to track down.  It seems that the Threshold 2 update to Windows 10 removed all my listening IP address entries!  You can check that by executing this command in a Command Window:

netsh http show iplisten

If your own IP address isn’t listed here you need to add it.  You can do that by using this command (use your own IP address obviously):

netsh http add iplisten 192.168.0.8

You can see more information about netsh here.

Share

PCL Profile 259 in Visual Studio 2012 on Windows 7, Xamarin, MvvmCross & ReSharper 7.1

Well, today was a lot of fun.  You can tell just how much fun from the ridiculous title of this blog post.

I’ve lost most of a productive day to this set of issues.  I was seeing some errors being reported by ReSharper 7.1 in my PCL and Xamarin Android solutions and couldn’t work out what the issues were.   They compiled without any compiler issues being returned and ran on the various emulators as expected, again without any issues or exceptions.  Consdering the error reported by ReSharper was Module ‘System, Version=4.0.0.0, culture-neutral’ should be referenced.  An error of that sort, if “real” should mean an application would have trouble even starting up let alone running.

resharper_errors

I’ve basically been round the houses trying to sort this out.

Considering the problem centered about MvvmCross I decided to have a look at the source for that so cloned the repository and started having a poke around.  Now the first problem you’re going to encounter given the VS2012 and Windows 7 constraints is that Windows Phone requires Windows 8 for development.  The WP8 SDKs won’t even install onto Windows 7 so those projects are dead in the water.  This target .NETPortable Profile259 which cannot be installed on Windows 7.

So when I opened the MvvmCross solutions on my machine I was seeing some very odd behaviours.  You can see some of the weirdness in the following screenshots:

mvvmcross

The Cirrious.CrossCore solution targets Profile 259 (the new Profile78 basically with Windows Phone 8.1 support thrown in – unavailable on Windows 7).  So what has been happening is any of my own projects that link to this library are trying to resolve system.dll v4.0.0.0 through Profile259.  Since I don’t have this profile ReSharper was correctly informing me of an issue but incorrectly informing that I’ll get a compiler error as a result.

In order to arrive at this solution I had upgraded ReShaper from 7.1 to 9.1 only to still see the issue.  Reinstalled all of Xamarin and even contemplated a fresh Windows install (not a small task).

The Solution

The solution turned out to be fairly simple.  Kid the system into thinking that my operating system DOES have Profile259 by copying the XML files from:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\SupportedFrameworks

Into:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile259\SupportedFrameworks

This doesn’t fix the issues I see when opening the MvvmCross solutions, they still compain about not finding system.dll but it has meant that my solutions that reference Cirrious.CrossCore do not throw up the problem of highlighting “non-issues” in my own projects.

So that was a hell of a learning experience.  And I did pull the trigger on an update to ReSharper 9.1 after complaining to JetBrains that 7.1 cost £110 and an upgrade to 9.1 cost £122!  So they gave me a 25% discount!  Yay!

Thanks JetBrains.

Share

Unit Tests in User Configurable Applications

Yesterday was another one of those little lessons in Unit Testing.

In one of the applications I work on there is a lot of clever string manipulation in order to derive intelligence from the data contained in the string.  Lots of array generation and scoring of individual elements within those arrays and so on.  The problem was during debugging within Visual Studio I was getting the desired output from the process I was unit testing.  All good.  The problem was as soon as that same test hit the build server it was failing.

I spent quite a while trying to track down what might be happening.  Since it was all geared around string manipulation I was looking for something related to any string comparison code I’ve written.  Is this a culture issue?  Am I making some obvious mistake with how some of the arrays are being treated?  Round and round looking at the same code trying to figure it out.

Those moments when your “coding cool” starts to ebb away and morph into pure frustration at mild annoyances.

After about an hour (a few cups of coffee) I suddenly realised what the problem was.

Since I was obviously debugging within Visual Studio this making use of the application in the context of which I have been using the application to debug.  Meaning that the user configurable options that I have set were being used.  This was not the case on the build server as the application hadn’t ever been run on that machine and certainly not in the context of the build servers build process.  So the two were not matching in configuration.

The setting in question allows the user to switch on deeper “fuzzy matching” on the string manipulation code.  If the code runs through it’s normal matching process and still hasn’t found an obvious match if this “Use Fuzzy Matching” item is turned out another set of rules come into play and the system then attempts to make a fuzzy “best guess” which, obviously, will create a different result.

So, todays lesson is when there are user configs involved in the code being tested, make sure you explicitly set these in each unit test!

Share

Xamarin Pairing Visual Studio 2012 to Mac for iOS Builds

Well, this was a bit of a pain in the arse.

When I initially paired Visual Studio 2012 to my Mac it all seemed to pair and be happy.  No problems with the pairing, the two found each other on the network and all was well.  Then it came to actually doing something.  FAIL.

Visual Studio was moaning about not being about to actually connect to it to perform a build.  I stupidly hit the Unpair button and then couldn’t work out how to “re-pair” the two.  The steps I performed to get this working:

  1. Run regedit and remove the Xamarin entries for you Mac under KnownServers
  2. Turn off the Mac Firewall (this seem insane and I’m looking for a better solution)
  3. Restart your Mac
  4. Go through the standard Pairing process
  5. Should be good to go!

Once I clear up the Firewall advice insanity I’ll update this post with anything I find out.

Share

Nuget Strikes Again

Honestly, for tool that’s supposed to make life easier and more robust I find myself battling with it often.

I’ve been upgrading some of the packages in one of my projects and ran into this pretty error:

The schema version of 'Microsoft.Bcl' is incompatible with version 2.1.31002.9028 of NuGet.
The schema version of 'Microsoft.Bcl.Build' is incompatible with version 2.1.31002.9028 of NuGet.
The schema version of 'Microsoft.Net.Http' is incompatible with version 2.1.31002.9028 of NuGet.
etc ...

Er …

OK, so initially I thought I’ll update the version of Nuget that TeamCity is running. Updated that, reran the build … same problem. Odd I thought … did some Googling around and found out that you have the MANUALLY … yes you read that right MANUALLY update Nuget … What the very fuck? This tool gets worse in my opinion the more I learn about it.

SO, go to you .nuget directory in your solution and run this:

nuget.exe update -self

So just what the hell is happening when VS tells me Nuget Package Manager needs an update? … yet my nuget.exes in the solution where still launguishing around at version 2.1 … honest, this is shit!

Now I’ve gotten my Debug build to work, but I keep getting these errors on my release build:

The build restored NuGet packages. Build the project again to include these packages in the build.

WHAT????

This is EXACTLY what Nuget is supposed to bloody do! That is one of it’s core functions … run the build again? Can you tell that I’m seriously pissed off with this tool right now?

Share

MVC Deployment – JavaScript – ReferenceError is not defined …

This had me stumped for a moment.

All the Javascript was there (linkable from bundle links in the page source), all the files were there, everything worked in dev (doesn’t it always?).

Anyway, if you’re seeing this error in your deployed applications there are a couple of steps to take.

Firstly you should download and install the Visual Studio tool JSLint.VS2012. Then set this up to show warnings and don’t set it up to fail the build. JSLint is not kind and very strict about things (your adherence to BP is your choice but recommended for sure!)

So, you deploy your app and BANG all your lovely JS is twatted. Never fear … pop over to your web apps Global.asax file and in the Application_Start method include this:

BundleTable.EnableOptimizations = true;

So now with this setting set you can launch your app in debug mode with all the Optimizations forced on to test minification and more closely model your testing to the deployed version.

Once you have that working and are seeing the problems more clearly you can start to work through the potential issues using the reports from your new JSLint VS plugin to fix the syntax and other formatting issues.

Share