Posted by: lluppes | March 19, 2015

Installing Mono and ASP.NET on a Raspberry Pi

In my previous post, I detailed how to get a Raspberry Pi up and running and ready for some serious .NET development.

I broke this down into two blog posts because doing it justice in one makes it two long:

Part 1 – A Beginner’s Guide to setting up your Raspberry Pi
Part 2 – Installing Mono and ASP.NET vNext on your Raspberry Pi (this post)

<TL;DR>    (a.k.a.  Too Long – Didn’t Read!)

These scripts are available on
A free eBook with all this info and more is available at

To use these script files, first fetch the first master file from the repository by entering a wget command in the command line window on your Pi.  At this point you will have a file, but the operating system doesn’t know that it’s a script, so you have to go tell it to give the file execute permissions by running the “chmod” command. Finally, run that command file using the “sh”, which will in turn fetch the other files and automatically mark them as executable.

chmod 755 getScripts
sh getScripts



Installing Mono (the wrong way)

Installing Mono seems to be (almost) as simple as running the following command:

sudo apt-get mono-complete

If you do that, check the version number by executing this command

mono --version

However… this will get you version 3.2.8, which is definitely not the latest.  If you use this, you will get a partially working Mono that will work for very simple programs and crash when you do something really complex like try to put a textbox on a screen.

Installing Mono (the right way)

Installing the latest Mono isn’t quite as intuitive as the previous way of doing it.  You need a few configurations first.  The following steps will load the latest build of Mono on your Pi:

sudo apt-key adv --keyserver --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mono-complete


You can do this automatically:

chmod 755 3_install_mono
sh 3_install_mono

When you are done, check the version number with this command, and you should see a 3.12* version:

mono –version


Running a C# WinForms Program

Running a Windows Forms application on a Pi (or Console App) is actually very simple.

  • Create and compile a Windows Forms App
  • Use WinSCP to copy the files from your bin folder to the Pi
    • Create a directory on the Pi to hold your files
    • Copy the EXE and any referenced DLL’s
    • You don’t need the .XML or .PDB files or the vshost.* files
  • Switch over to the Pi and double click to run the program
  • Voila – it should just work!

I’ve tested this with a fairly simple forms program that had dialogs, file IO, etc., and had no problems.  That’s about as far as I’ve explored so far.  I’ll update this with more info later as I experiment more with this.

Installing ASP.NET vNext

One of the awesome features of the new version of ASP.NET v5 is that it’s designed to run on many operating systems, including on a Mac and Linux.  However, there are a couple of pieces that you need to install in order to make your new ASP.NET vNext pages work – primarily the KVM and Libuv modules.

Update Your Certificates

In order to get those programs installed properly, you’ll need some updated certificate.  Update the certificates on your Pi with these commands.  You’ll be prompted multiple times to confirm the certificates, and they will warn you that they certs are invalid (don’t believe it!).  Just say “Y” to each certificate and you should have no problems with this.

sudo certmgr -ssl -m
sudo certmgr -ssl -m
sudo certmgr -ssl -m
sudo certmgr -ssl -m
mozroots --import --sync

You can do this automatically:

chmod 755 4_install_certs
sh 4_install_certs

Install KVM

To install KVM (the kernel Virtual Machine) use these commands:

mkdir ~/sources/
mkdir ~/sources/aspnet5
cd ~/sources/aspnet5
git clone git://
sh ~/sources/aspnet5/home/
echo "  Run this command:      source /home/pi/.k/kvm/"
echo "  Then run this command: kvm upgrade"

I’m not sure why, but the last two commands fail when I try to include and run them in this batch file, so I had to run them manually…

You can do this automatically:

chmod 755 5_install_kvm
sh 5_install_kvm

Install Libuv

Libuv is a cross-platform support library which was originally written for NodeJS, designed around the event-driven asynchronous I/O model.  Install it using these commands:

tar -xvf libuv-v1.0.0-rc1.tar.gz
cd libuv-v1.0.0-rc1/
./ -f make -Duv_library=shared_library
make -C out
sudo cp out/Debug/ /usr/lib/
sudo ln -s /usr/lib/

You can do this automatically:

chmod 755 6_install_libuv
sh 6_install_libuv

Running Your First ASP.NET MVC6 Page

After installing and configuring the app, run these commands:

cd /home/pi/sources/aspnet5/home/samples/HelloMvc
kpm restore
k kestrel

The unset RUNLEVEL command is there because I keep getting the error “System.ArgumentException: An element with the same key already exists in the dictionary”.  If you run the command “printenv” you’ll see that you have two rows that say runlevel=.  The command “unset RUNLEVEL” will remove the second one, then you can run the k kestrel command and it should work. There must be a way to get rid of this, but I haven’t found it yet!

If everything worked and was installed properly, you should see the word “Started” in your command window.  Open a browser and navigate to http://localhost:5004/ and you should see the default welcome screen.


To replace the welcome screen with the more typical index page, you have to add a route in the startup.cs.  Edit the HelloMVC/startup.cs and comment out the UseMvc() line and add a new route:

app.UseMvc(routes =>
    name: "default",
    template: "{controller=Home}/{action=Index}/{id?}");

If you want some customized content, edit the HelloMVC HomeController.cs to have User.Name equal to your name.

User user = new User() {
    Name = "Lyle",
    Address = My address"

Go back to your command window and hit Ctl-Z to stop the process.  It’s stopped but actually still running so you will need to type in the command “kill %1” to really kill it.  Once it’s gone, type in “k kestrel” command to restart it and then refresh your browser, and you should end up with something like this:



In Conclusion

I hope this walk through helped you out.  I had a hard time finding all the right details for this – there were little bits and pieces everywhere and allusions to some of this, but nothing comprehensive that put it all together.

I’ll be adding more to this in the near future as I get more content about how you can create a fully working ASP.NET vNext / MVC6 application running, and a working sample project you can download from the GitHub repository.

You can download a free eBook with all this info and more at:


Posted by: lluppes | March 19, 2015

.NET on a Raspberry Pi 2???

The Raspberry Pi has been a great hit, selling over 5 million devices since its introduction in 2012.  People have used it in schools to teach children about programming, and hobbyists have been building lots of interesting projects with it. One of the great things about the Pi ecosystem is that everything is very inexpensive.  The latest Raspberry Pi 2 has a 900 MHz quad-core processor for only $35 — wow!  You can buy all of your components and have a fully functioning computer for less than $100.

However, one of the problems (although some people might say that’s an advantage!) is that it’s a Linux computer and uses languages that are not familiar to the millions of experienced .NET developers out there right now.  Sure – we could all learn Python or Scratch or whatever the latest small device language is… but why?

What if we could use the .NET languages we know and love and use most of our installed code base and then deploy that on these little tiny computers?  There are millions of .NET programmers out there with billions of lines of tested code in their project libraries.  I believe you can use that code easily on the Pi, and I’ll show you how you can do it in just a few short steps in this guide.

<TL;DR>    (a.k.a.  Too Long – Didn’t Read!)

These scripts are available on
A free eBook with all this info and more is available at


Divide and Conquer

I’ll break this down into two blog posts because doing it justice in one makes it two long:

Part 1 – A Beginner’s Guide to setting up your Raspberry Pi (this post)
Part 2 – Installing Mono and ASP.NET vNext on your Raspberry Pi

Time to Buy Some Goodies

You need to see this for yourself and getting started is relatively inexpensive.  Here what I would recommend that you start with for your shopping list:

Raspberry Pi 2 Model B (1 Gig) $ 35.00

32G microSD Card (You could go smaller, but why? To save $5?) $ 13.99

Mini Wireless Keyboard (It’s really cool!) $ 13.99

USB WiFi Adapter (Less wires is better, right?) $ 14.99

Plastic Case $ 9.49

Total $87.46

There are also a couple of things that you will need that you probably already have laying around your office:

  • A USB power supply with a micro USB cable (an old phone charger will probably work just fine – you need a 5V adapter).
  • You will need a spare monitor of some kind that supports HDMI. You don’t really need a dedicated monitor – you only really need it during the setup, so you can share with your computer if needed.  If your monitor only has a DVI connection, you can buy an HDMI to DVI adapter
  • HDMI – DVI Adapter Cable  $7.99

Once you have these components, you’re all set to go.

Installing the Operating System

Once you have that little box of Raspberry in your hot little hands, it won’t do any until you install an operating system – these little computers don’t even have a hard drive.  To get rolling, you will need a formatted microSD Card.  You might think you could just format it in Windows Explorer, but you are better off using a utility that is designed to format SD cards optimally.

You can download a free formatter from
Install and open the utility, insert and select your microSD card, and begin formatting.

There are several operating versions available at
If you feel like you must be a real geek, go ahead and install one of the many Unix variants.  Be aware though that as of the time of this document, not all of them work on the Raspberry Pi 2, so I’d stick with Raspbian for now.  If you just want to get started quickly, simply download the NOOBS install – it’s already prepared to make this quick and easy.  All you have to do is unzip the downloaded file to your PC, then copy all of the files on to your newly formatted SD card and you are ready to boot up your Pi.

Initial Power Up

Connect all of your new hardware, put microSD card with the extracted NOOBS files into your Pi, and then power it up.  You will see a NOOBS installation menu – choose Raspbian from that menu:


The installer defaults to the Great Britain locale (because the Pi was created there), so you may want to change the language and keyboard to US instead of GB.  The one issue I found with using the GB keyboard that made me change it is that I could not find a way to enter the “\” character. (Maybe there is a way, but I couldn’t find it!)

Once you click “Install” the Pi will go to work rebuilding your SD card with the operating system.


After a few minutes, you’ll be ready to reboot and configure your Raspberry.  The first time it boots up you will automatically be greeted with the Config Tool.


You don’t have to set most of these because NOOBS takes care of most of it, but you will want to change these three options:

  • #2 – Change User password – the default User Id is “pi” and password is “raspberry”. Since every noob knows this, if you want any kind of security, you really should change this (you can always do it later — just don’t forget!)
  • #3 – Enable Boot to Desktop – Select “Desktop Login as pi at the graphical desktop”, unless you always want to have to type a command at the command line to start the user interface.
  • #4 – If you changed the language to English on the install screen, you will need to select the Internationalisation Options and install the “en-US.UTF8 UTF8” locale, and then change the default keyboard on the follow up screen. It will then take a minute or two to generate the proper locale files.

Tab down to Finish and press enter and your Pi will reboot.  If you miss Option 3 and end up at the command line instead of the desktop, you can always start the GUI with the command “startx”. If you want to get back to this screen later, just open a command prompt and type “sudo raspi-config”

It’s Alive!

Congratulations – You now have a working Raspberry Pi!  Granted, it doesn’t do much yet, but it’s a start.  You should be seeing the home screen:


The first thing you will need to do is to get your network connection running.  If you connected an Ethernet cable hard line, it should be already up and working already.  You can open a web browser and browse to any website to verify this.

If you want to use WiFi, you will have to do a bit of configuration to get it up and running.  Open the Menu -> Preferences -> WiFi Config menu item.  On the “wpa_gui” window that pops up, do the following:

  • Select the Manage Networks Tab.
  • Select the Enabled radio button
  • Click Scan button to open Scan Results popup window
  • Select your network and then enter in your wireless key in the PSK textbox on the popup screen

Before you leave this screen, you will want to find your IP Address (you’ll want that later), located on the Current Status tab.  If you want to find it use a command line, use the “ifconfig” tool (a cousin to the Windows ipconfig command).  I usually add a “grep 255.255” command to filter it down to just the line you are interested in. (grep is a Unix search utility), like this:  “ifconfig | grep 255.255”   Once you have an IP address, open your web browser and go to some website to test out your connection.

If you want, you can change your Pi to use a Static IP address, which might make it easier down the line.  I don’t usually bother with this as I haven’t had an issue using DHCP on my home network because it almost always keeps the address, and I can always look it up if I need to.

Remote Desktop

I’ve found that the easiest way to work on the Pi is to do it with your normal desktop and use a remote desktop program to access to your Pi.  The standard Remote Desktop program in Windows won’t work, but there is an easy (and free!) program available called TightVNC.  You will need to install the server on your Pi, and then run a client on your Windows Desktop.

To install TightVNC on your Pi, open a command line window and enter the following commands:

sudo apt-get install tightvncserver autocutsel

Here is an explanation of what the commands do:

sudo: asks the system for elevated rights
apt-get: is the Advanced Packaging Tool command (kinda like NuGet)
install: is the action for apt-get, which followed by the packages that you want apt-get to install
tightvncserver: is the name of the program you want to run

My favorite explanation of what the sudo command does is from Randall Munroe’s always excellent xkcd comic:


When you issue the “tightvncserver” command, and the VNC Server starts for the first time, you will be prompted to supply a password, and then each time you start your VNC client you will be asked for this password.  You can say safely ignore and say No to the view-only password.  Note the message “New ‘X’ desktop is raspberrypi:1”.  The “1” tells you that VNC is listening on port 5901.  If you run this command again, it would start another program and reply with “raspberrypi:2”, which would mean it was running on port 5902.

To install the TightVNC Client on your Windows Desktop, download the program from and load it on your system.  To connect to your Pi, enter a Remote Host of your IP address plus the “:5901” and click Connect, then you will be prompted to enter your VNC password.

You should now have a remote session open from your Pi on your desktop so you can use your normal mouse and keyboard and start the system update patching process.

Enable Copy/Paste in TightVNC

By default, one feature that is not enabled in TightVNC (that I think is sorely needed!) is the ability to copy and paste from your desktop into and out of your Pi.  To enable that, you will have to install one small feature.  If you followed my instructions earlier when you apt-get installed tightvncserver, you added another package named “autocutsel”.  To enable it, you will need to edit the pi\.vnc\xstartup file and add one extra line of configuration.  The “.vnc” directory is a hidden directory, which is indicated by having a period as the first character of the directory name.  Note that this directory actually won’t exist until you run tightvncserver for the first time.  Open the File Manager, and turn on hidden files under the view menu, then Navigate to the .vnc\xstartup and right click and open up with the text editor.  Find the line “xsetroot –solid grey” line and then add a new line after it that contains the “autocutsel –fork” command.



Save the file and you should be all set. Stop and restart TightVNCServer and you should now be able to copy and paste from your desktop to your Pi to your heart’s content.

Initial Setup

As you read through this manual, you will see a lot of commands and files that will set up your Pi.  I’ve included them in this document so that you can see what they do, but you probably don’t want to type them all manually.  To help you out, I’ve published all the scripts out to a GitHub repository:

To use these script files, first fetch the first master file from the repository by entering a wget command in the command line window on your Pi.  At this point you will have a file, but the operating system doesn’t know that it’s a script, so you have to go tell it to give the file execute permissions by running the “chmod” command. Finally, run that command file using the “sh”, which will in turn fetch the other files and automatically mark them as executable.

chmod 755 getScripts
sh getScripts

Here is an explanation of what the commands do:

wget program that retrieves files from an http* source
chmod 755 marks a file as executable
sh starts a command line interpreter to run some commands

Auto-Start TightVNC

At this point, you have the TightVNCServer installed and running, but if you reboot, it won’t start up until you enter the “tightvncserver” command again.  If you want it to start up automatically (and you do!), do the following.  Create a new file in the init.d directory.  This is protected directory, so you have to use a sudo command to start your editor and get elevated privileges.  At this point most tutorials will spell out a “sudo nano…” command for you.  Why?  Because that’s the Unix admin way to do it, with the ubiquitous and obtuse Nano editor.  But we are .NET programmers and we know there are better tools available, so let’s use them!  Leafpad is the alter ego on the Pi of NotePad, so let’s use that. Enter the command:  “sudo leafpad” and then enter this script and save it as “/etc/init.d/vncboot”.

# Provides: vncboot
# Required-Start: $remote_fs $syslog sudo etworking
# Required-Stop: $remote_fs $syslog sudo networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop TightVNCServer at boot

export USER='pi'
case "$1" in
  echo "Starting VNC Server"
  su $USER -c '/usr/bin/vncserver :1 -geometry 1280x800'
  echo "Stopping VNC Server"
  pkill Xtightvnc
  echo "Usage: /etc/init.d/vncboot {start|stop}"
  exit 1
exit 0

Tip: You can fetch the contents of the file from GitHub and then simply copy it to the directory using these commands:  (if you ran the getScripts command earlier you already have it, so you can skip the first line)

sudo cp /home/pi/1_vncboot /etc/init.d/vncboot

Once you have this file in place, you’ll need to mark it as an executable script with this command:

sudo chmod 755 /etc/init.d/vncboot

You can now start or stop the service manually by running the following commands. Make sure you do this at least once so that you set up the remote access password.

sudo /etc/init.d/vncboot start
sudo /etc/init.d/vncboot stop

I’m not sure why, but it seems to need a reboot here before you do the next update command or it doesn’t work…  so you should reboot your Pi now by executing the command: “sudo reboot”

Just having that file in the directory won’t make it auto-start.  To do that, you will have to enter the command:

sudo update-rc.d vncboot defaults

Reboot your Raspberry Pi, and you should be able to connect across the network using the VNC Viewer and now you won’t need an extra keyboard, mouse, and monitor for your Pi cluttering up your desktop anymore!

Applying System Patches and Updates

Like any new operating system, there are always patches and updates that you need to install when you first install an operating system.

Open a command prompt (LXTerminal) and run these commands:

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install htop autoconf automake screen
sudo rpi-update
sudo reboot

You can fetch these commands from GitHub using these commands:

chmod 755 2_update_os
sh 2_update_os

Tip: If the script stops and asks you to confirm with a “Y/n”, make sure you enter an UPPER case Y, otherwise sometimes the script just stops.

Here is an explanation of what the commands do:

sudo: asks the system for elevated rights
apt-get: is the Advanced Packaging Tool command
update: will download software package lists
dist-upgrade: updates the software packages (this different than just using “upgrade” as it retrieves all the dependencies also)
rpi-update: will update the Raspberry firmware
install: will install a new program
htop autoconf automake screen: are useful utilities

Once everything is updated, reboot with a “sudo reboot” command.

Ready To Move On?

Your Pi should be all set to go and you’re all ready to starting doing something cool with it!

Part 2 of this series will detail how to properly install Mono on your Pi, and then get some .NET programs running, and how to configure and run ASP.NET vNext.

Posted by: lluppes | March 17, 2015

Surface Pro 3 Tips

SurfacePro3I don’t know about you, but I love my Surface Pro 3.  In fact, I like it so much, that I have one in my home office that I bought for my personal consulting business, and I got another one to use at my daytime job, so I actually have two of them now!

Having worked with the Surface for a few months now, I have a couple of tips that I would like to share, in the hopes that they will help someone else.

Can’t get to Sleep?

If you’re a developer like me, and you have a Surface Pro 3, you may have installed Visual Studio.  I recently installed some new portions VS2013 and VS2015 (specifically the Windows Phone developer tools), and I starting having issues with sleep mode on the Surface. The Surface supports a “Connected Standby” power mode, which makes it very quick and easy to close the lid of your Surface, then open it and wake it back up again almost instantly.

However, as it turns out, that mode is incompatible with the Hyper-V program, which is installed and required to run the Windows Phone Emulator. Once you install those Windows Phone tools, your “Connected Standby” mode is gone. In fact, if you go to the Power Options screen, you will find that you can’t even set your power button to Standby — because it’s not even there anymore!

Fortunately, there is a solution — there is a simple command that you can enter at the command line
(Note: you must start the command prompt in Administrator Mode for this to work).

To turn this “feature” off:
bcdedit /set hypervisorlaunchtype off

If you want to run your WinPhone emulator, re-enable this “feature” with this command:
bcdedit /set hypervisorlaunchtype auto

Once you do that, the wonderful “Connected Standby” and Sleep settings are back!


My DVD Doesn’t Work!

The Surface Pro does not have a built-in DVD player, and I don’t often use one, but occasionally I do need to read or write to a DVD, so I have a great little external DVD that I bought on Amazon for about $32.  However, the first time I plugged it into the USB port on my Surface, it didn’t work, and no amount of persuasion would fix that.  As it turns out, the answer was pretty simple.  The USB port on the side of the Surface doesn’t supply enough power to run the DVD – all I had to do was to plug the DVD into the port on the docking station and magically everything worked!

Print Screen

If you haven’t noticed, there is NO Print Screen button on the Surface keyboard.  This one is pretty simple – press the Fn + Win + Spacebar and you’ll get a Print Screen in the clipboard.

External Touch Screen = Blue Screen of Death

I still haven’t figured out the answer to this one yet…  I bought a nice refurbed Acer 23″ TouchScreen Monitor from NewEgg for about $215, and it works great – sort of…   It does work really well, except for the fact that when I had the USB plugged in to my docking station and the touch features enabled, I would get random Blue Screen of Death crashes without any warning.  I was getting them about once a day before I unplugged the USB cable.  Once I unplugged it, the BSOD’s went away.  I did look and I had the latest and greatest drivers.  I’m not sure what else to try here – I really haven’t taken the time to try and figure this one out.  Once it stopped crashing, I just stopped caring (it’s still a nice monitor!)

I hope these tips help you!


Posted by: lluppes | February 16, 2015

Deploy Multiple Projects into One Azure Website

If you have ever wondered how you could create multiple web projects in Visual Studio and then deploy those projects to a single Microsoft Azure Website, this post can show you how. Having multiple projects is a good way to separate your project into small manageable tasks that can be deployed and managed independently. Having to only pay for and manage only one website is even better!

​​​​Microsoft Az​ure Setup

Create and deploy your Azure Website like any other Azure Website. Once the site is deployed, there is one small configuration change you have to make. Select the Website in the Azure management console, then navigate to the Configure section.

Scroll all the way to the bottom of the section and enter the name of the virtual application and the path that it should use. By default, the “/” is the root directory and points to the “site\wwwroot” directory. Add in the custom directory that you want created, appending the name of the application after both of those values, like this example where I’ve added the “Globalization” and “Mobile” virtual applications:


Visual Studio Project Setup​​

Create a standard website, then set up the publish to Azure with the standard Azure Website deployment setup, with one minor exception. Manually change the deployment path in the Connection section to have the application name in the path in the Site Name and Destination URL.

Publish the application normally now, and it should get deployed as a virtual directory inside of your Azure Website.


  • When the application in the root of the Azure Website is deployed, make sure that the “Delete All Files” is NOT checked, or it may remove your child application directories.
  • There may be​ issues with the web.config file when deploying child applications. For example, if you had the following in your section in both the root application and the child application:
    <add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />

    This line would cause the application to fail when run as it inherited the values from the root application and then tried to add this module again.

I hope this helps you out!


Posted by: lluppes | January 12, 2015

MVC 5 Website works locally but fails on Server with 403.14

I ran into this problem recently and it took a while to figure out.  My website worked perfectly locally, but when it was deployed to a server, it came up with a blank screen and an error code of 403.14 (Forbidden).

As it turns out, I was using the API Help module (which, by the way, is a totally awesome tool — if you are creating APIs you need to check it out!!)  That tool is looking for an XML documentation file that is created upon build.  If you don’t include that file in your publish process, you’ll get this relatively nasty error, and have pretty much no clue why.  Simply include this file in your deployment and the error should go away.

Hope this helps!


Posted by: lluppes | December 5, 2014

The Internet of Convoluted Things


I saw this blog entry today and it really hit a note with me.

We are advancing towards a world of home automation and smart devices, and for all of us technical geeks – that’s great!  However, it’s just not workable for normal people.

Think about the new enabled light bulbs…  to turn on the light bulb you have to  1) find your phone  2) unlock your phone  3) start the light bulb app  4) tap the bulb to turn it on.  I might find it really cool that I could do that from my phone or tablet.

Most normal people (like my wife) would look at you and say – why wouldn’t I just flip the switch on the wall…?  isn’t that easier?  so…  now you’ve succeeded in making the light bulb more difficult to use?

As we embark on the journey towards smart connected devices, we need to think hard about these things and figure out how to design the devices and the surrounding ecosystems so that things are easier to use and provide value – not just create IOT enabled things because we can.


Posted by: lluppes | December 8, 2013

MVC5 Authentication Roles Failure

I’ve been doing a lot of work lately with ASP.NET MVC5, and with most of my development being in a corporate environment, we almost always need authentication in our projects.  MVC4 introduced a new authentication model and MVC5 made major changes to the authentication model once again.

In a recent project, I was vexed with a very strange error that took me hours to resolve.  On my development machine, I have SQL Server installed, but do NOT have SQL Express installed or running.   Some of my other MVC5 projects were working just fine with Authentication and Roles.  In this particular project, the authentication was working just fine, and was creating users in the database as they authenticated.  However, as soon as you tried to check a role using either the explicit Roles.IsUserInRole method or through a standard MVC decoration like [Authorize(Roles = Constants.Role.AdminRole)], the page would sit and spin several minutes, then time out with this error.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
SQLExpress database file auto-creation error:   [stack trace – blah, blah, blah]
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.33440
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Apparently the Role Manager was attempting to create a SQL Express database in order to validate the roles, and it was unable to do so.  During my searching and experimenting, I found many red herring suggestions which did not help at all.  Since this project was using MVC5, the SimpleIdentity provider was NOT being used, as MVC5 uses the new AspNet.Identity libraries.  So most of the suggestions on this topic offered up things about SimpleIdentity, WebMatrix, adding a <RoleManager> or “enableSimpleMembership” tag in the web.config, update InitializeSimpleMembershipAttribute, etc. – and none of these worked.

Oddly enough, what did work did not seem at all intuitive to me:  removing the RoleManager in the web.config modules section.

    <remove name="RoleManager" />

This didn’t seem at all obvious to me since I had not actually added it, and I was not running in the context of a server which had a root web.config file which added it.  I still don’t know  how or why it was trying to load the older RoleManager.  In any case, adding this line allowed the MVC5 Role Manager to kick in and then everything worked fabulously.  As I’ve said – I’ve had other MVC5 projects which used Authentication and Roles and had no problems, but there was something different about this project which caused this failure.

I hope this helps someone else as this strange error cost me hours of down time.

Posted by: lluppes | June 26, 2013

The Inexpensive DIY Standing Desk

Last year I spent a lot of time working on my book, speaking at conferences, and working on this blog.  This year I’ve been focused a little more internally and haven’t written another book or signed up to speak at conferences.  I’ve spent a lot of time trying to get back into the shape that I was in several years ago (before middle age gave me my current round shape!)  I’ve been working out twice a week with a trainer, and playing racquetball two or three times a week, and it’s really helped me physically.

My latest effort to improve my health is to try out a standing desk. There are lots of articles out there on why standing up more is a good idea, such as these:

Sitting is Killing You (Medical Billing & Coding)

Sitting for Too Long Is Bad for Your Health (WebMD)


Image from Medical Billing and Coding Article

Assuming you are interested in trying this, it takes a lot of time and effort to purchase everything and set it up just to see if you like it or not, so I came up with a very quick and inexpensive temporary solution.  I’ve got a cubicle with enough space to keep my sitting computing area and put a stand-up area right beside it.  To get a feel for how I would like it, I built a temporary standing desk using copy paper boxes.



Everybody’s got these kind of boxes around their office, so it’s a matter of just a few minutes to put some up on your desk and find the right height for you and give it a try.  Once you’ve done this for a few days and determined that this really does work for you, then you can move on to creating a nicer desk.

If you Google “standing desk Ikea”, you can find several people that have created simple standing desks for about $25 using Ikea Lack desk components, and those seem to work pretty well.  However, that didn’t exactly fit what I wanted, so I set out to building my own without spending too much money.  If you don’t want to go to the trouble of building it, the Ikea Lack desk is pretty simple, or you can just buy one like this on Amazon.

As I understand it, the two general ergonomic principles that you want to follow is that the top of your monitor should be just above eye level, and your keyboard should be at or just below your elbows so your arms are bent at about 90 degrees.  Since I have a cubicle wall with adjustable tracks built into it, it made sense for me to put a shelf up there to hold my monitors, then create a simple stand for my keyboard.

I went to my local Home Depot and picked up about $30 worth of materials: (similar products are available at any Home Depot, Menards, Lowes, etc.)

  • 1 – 12” x 48” Melamine Shelf – Monitor Shelf (~$8.50)
  • 2 – 12” Shelf Brackets (~$5.00)
  • 1 – 12” x 36” Melamine Shelf – Keyboard Stand Top (~$7.00)
  • 1 – 8” x 36” Melamine Shelf – Keyboard Stand Back (~$5.00)
  • 1 – 10” x 24” Melamine Shelf – Keyboard Stand Legs (~$4.50)
  • 4 – #8 1.5” screws ($1)
  • 9 – #8 1” screws ($1)

Start by cutting the 24” long shelf in half so you have two 12” boards that you use for legs.  I’m about 6 foot tall, and my normal desk is about 28.5” high, so this puts my keyboard at about 41” off the floor.  You’ll want to adjust this height to fit your frame.   If you’ve tried it out with temporary boxes, you should be able to measure it out and figure out how high your keyboard should be. If you have a table saw, split the back board so that you have a 1” x 36” strip that you can use for cleats, then cut 8” off each end of that 1” cleat board so you have three pieces. If not, you can buy a small piece of 1×2 to use for cleats – the only difference is that it won’t match exactly.


Use a countersink (if you have one) and pre-drill holes and screw the legs to the back board.


You should end up with something that looks like this:


Set the completed back board on the top of your keyboard shelf and mark out where the cleats should go, then screw the cleats to the bottom of the top board.  If you’ve got a countersink drill bit, it’s best to use that to make the #8 x 1” screws set flat into the board.  Be very careful when you tighten these in – if you have inexpensive lumber with a particleboard core, and you use too much pressure (for example, if you drive them in with a drill), you’ll crush the cleat and break it in half.  It’s best to hand tighten these screws.


Once you have the cleats in place, drive one or more screws from the cleats into the back board to hold it in place.  By putting them in here, you hide all of the screws so your finished surfaces are nice and clean.


When you are done, you should have a nice looking table with no visible screws in the top, and only two small visible screws on each side.


Here’s the final standing configuration on my desk:


I used a bit of black electrical tape to tape the monitor power and video cords together so that when I move them they don’t get tangled.  It takes only a minute to switch between the two setups.  I don’t always make it all day standing – part of that depends on what else I have going on.  If I’ve had a hard workout in the morning, or if I’m playing racquetball later in the day, I’ll spend more time sitting.  Other days I’ll spend most of the day standing.  Either way, I’ve got the flexibility to choose.

One last thing – it does tend to get a bit uncomfortable standing on your feet for long periods, so I would recommend buying a 24” x 36” Sublime Gel Mat ($42-59 from Amazon).  There are cheaper ones available, but this one is highly rated and reviewed.  We used this in on our kitchen and it’s a really good one that should last you a long time.


I hope this post helps you out if you’re thinking of doing this.  Give it a try – if you use the copy paper box method, you’ve got nothing to lose other than a few minutes of your time.  If you find out you like it, then you can pursue more permanent solutions.

Posted by: lluppes | February 1, 2013

SyncFusion Metro Studio – Bargain Priced (for now!)

As I’ve been doing WinRT development the last month or so, I have found a couple of bargains out there.  SyncFusion has released a preliminary version of their WinRT toolkits at a bargain prices – the Essential Studio for WinRT for only $99!  The price will rise later this year as the toolkit matures, so you are strongly advised to take advantage of this price while it lasts.  It’s got some good tools right now that will continue to get better through the year.

One nugget in this toolkit that I’ve used quite a bit as I’ve been developing WinRT apps is the Metro Studio icon builder.  It has a nice collection of royalty-free icons that you can use in your applications (not just Windows Store apps!), but what I really like is how I can use them in my WinRT C#/XAML applications.  Unlike many icon collections, this one comes with a nice customizable editor:


You pick a category select an icon, and you can customize it by turning it or changing the colors, etc. – all the usual stuff you would expect in an icon editor. But here’s the cool part for Windows 8 C#/XML developers:  you can export this icon definition as a XAML path.  Why is that important?  I’ll show you.

Click on the XAML button, and you should see the following:


There’s a lot of extra stuff in there that you don’t really need — all you really need is the second Data attribute, which I highlighted.

In order to use this in your project, you need a button definition that can utilize a XAML path.  In your C#/XAML Windows Store app, go find the file StandardStyles.xaml, which is typically located in the Common folder.  There are a lot of Standard AppBarButton styles in there waiting for you to uncomment them which are very helpful, but you will need to add in this new button style code:

<Style x:Key="PathBasedAppBarButtonStyle" BasedOn="{StaticResource AppBarButtonStyle}" TargetType="Button">
  <Setter Property="ContentTemplate">
        <Path Width="20" Height="20" Stretch="Uniform" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=TemplatedParent}}" Data="{Binding Path=Content, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>

Now go into your XAML page where you actually want to use a button, and add a new button like this:

<Button Style="{StaticResource PathBasedAppBarButtonStyle}"
Content="[PATH DATA GOES HERE]" />

Paste the “M0,44.993L64…” code from up above into the Content attribute, like this:

<Button Style="{StaticResource PathBasedAppBarButtonStyle}"
Content="M0,44.993L64,44.993 64,51.735001 0,51.735001z M18.628,37.962999L45.372002,37.962999 45.372002,42.269 18.628,42.269z M4.4440002,3.855999L4.4440002,34.444999 59.556004,34.444999 59.556004,3.855999z M0.41899967,0L63.581001,0 63.581001,37.666 0.41899967,37.666z" />

That’s it!  When you run your app, you’ll have a customized icon that fits your app perfectly.  No image files to include, just a nice simple path string.  You can tweak the icon in the editor, then just update in the Path Data and you are all set.   Keeps things small and fast – pretty sweet!

Download your free trial version now at and give it a try!

Posted by: lluppes | January 15, 2013

My First Windows Store App!

Well, the holidays are over, and it’s time to do some documentation.  Last November, I bought myself a Microsoft Surface and set about learning how to write programs for WinRT, and blogged about “Do I take the red pill or the blue pill?“, as I struggled with whether to use HTML/Javascript or C#/XAML, and learning about all of the new and/or missing features of WinRT.  I tried both the red and the blue pills, and I think both of them left my stomach unsettled.

Don’t get me wrong – I really like the new style of the “formerly known as Metro” apps in Windows 8.  I feel like I’ve had a big change in my design style, making it cleaner and lighter as Win8 Store Apps should be.  But along the way, I’ve had my share of frustrations as I’ve tried to do things that were simple in other environments but just plain didn’t work in WinRT apps.  And that’s another thing – just what do you call them?  Metro?  No.  WinRT apps? Windows Store Apps?  Windows 8 Apps?  Maybe…  Windows 8 still confuses me sometimes, even though I’m using it every day on a desktop, laptop, and Surface, and writing apps for it.  But I digress…


After many hours of work, I released my first app into the store in early January.  TimeCrunch is a time tracking app that dates back many years for me.  I’ve been using a version of this since back when I wrote it in 1997 using Microsoft Access.  It morphed into a classic ASP app as I learned that platform, and now is available for anyone to use as a free Windows Store App, and it may yet morph one more time.  The free edition stores the data locally using a SQLite database (which I’ll blog about more in the near future).  I’m working on another version that will run as an Azure based web application, plus an API that can be called from a Windows Store App, so you can share your data across multiple devices.  I wish I had more time to devote to this, but haven’t found the time yet for it.  Stay tuned to this blog for future announcements of it as that develops.

Older Posts »



Get every new post delivered to your Inbox.

Join 190 other followers