MachinaDei.com Me.Catholic.Business.Technology.Dev(VB.NET, Excel, Office)

15Sep/110

Deploying a Lightswitch Application to WinHost.com

LightswitchPreface: Over the past couple of weeks I have been building a Lightswitch application to manage sales quotes. It is one of the biggest issues I have at work and management of quotes with our CRM is a pain. So I decided to build my own app and then work on a export function later to send to our CRM to keep it “up-to-date” as I am forced to do want to make sure management can spy on us gets what they need and so they can make effective decision on who to fire.

So with that said, here is how to deploy a 3 tier Lightswitch application to WinHost.com. For my personal project I am also using an XtraReport from DevExpress, so I will add that step in case you are too. Many thanks to Seth (twitter @sethjuarez) from Developer Express for fixing my horrible code and putting up a post for others to learn from. Seth helped me understand how to pass a parameter to a XtraReport. This seriously makes reporting building easy and shows DevExpress is a great company to do business with.

Before we begin, I figured this out from reviewing the tutorial on ShownTheLight.com. The tutorials are good, but since I am more of a novice on Windows Hosting I decided to create this tutorial. My version is intended to help the more non-developer do this (e.g. geeky business guys like me).

The Basic Sample App Deployment….

I am assuming you’ve built some test or prototype app and are ready to deploy for testing or even release; you could also just deploy the course manager end-to-end example to learn from. You’ll want to make sure that Visual Studio is set to compile for debug or release; whichever is applicable to your situation.

First, you need a WinHost.com (affiliate link) account… Ok, now that they have your hard earned money lets roll.

A little pre-work is involved… You will need to set the ASP.NET version to .NET 4.0. You cannot mix .NET version on a WinHost.com account. So if you need .NET 3.5 for other website applications (e.g. blog, CMS, ect..), you’ll need a separate account and domain to use or all applications must target .NET 4.0. Not an issue for me at this point, but I can see this as an issue for other uses.

Second, we need to create a MS SQL 2008 R2 Database.

WS-3

WS-4

 

Do remember to copy all of your MS SQL settings, including the password. I keep mine in a text file that is stored in the VS project and I upload it to my subversion repository. (I use project locker, really good service).

Third, we need to set an application starting point…. I suggest deploying to a sub directory (yourdomain.com/LSApp) and setting the directory as a starting point. Not sure if you really have to, but it is working for me so I’ll recommend it.

WS-5

Fourth, we need to deploy our Lightswitch application. In my case this is Desktop application hosted in an IIS Server. I let you choose between Web and Desk…  For a shared host remember to NOT check the prerequisites are installed. I had issues, until I unchecked that.

WS-6

WS-7

Fifth, Set the site preferences… For WinHost.com you need to know the MS Deploy “Service URL” (Example - https://<yourserver>.winhost.com:8172/MsDeploy.axd), your “Site Application” (Example – YourDomain.com/MyLsApp) and of course your User Name and Password (for WinHost.com it should be your FTP user name and password). Do remember to set it for “untrusted certification”. Do remember all of these settings are on your Winhost.com control panel.

WS-9

Sixth, with the MS SQL DB information setup your database connection strings or if you are connecting to an existing DB ensure you connection string is correct.

WS-10

Seventh, if you are using the Developer Express XtraReport for Lightswitch you need to verify the connection string here. Honestly, I don’t know if you need to re-type this, but I am doing so and it is working. So that is good enough for me…

WS-10 (2)

Eighth, specify a cert if you have one…

WS-11

Ninth, time to publish after you confirm the setting look right….

WS-12

Tenth, hit Publish and here we go…

WS-13

Eleventh, if you are deploying a XtraReport with you Lightswitch application you need to remember to also FTP over the dll’s for DevExpress. This will prevent the “GetAuthenticationInfo” error; which drove me nuts for a week. The dll’s go to the “bin” directory on the server.

Ok… Go run your Lightswitch app.

WS-16

A Few Notes to help with Gotcha’s!

1. Do expect a performance difference from local network (2 tier deployment – testing) compared to a hosted app. A lot of information is transmitted between the SQL database and the local PC; for either web browser or desktop 3 tier host.

2. Did you get this error? To see full error, open the Web.Config and set CustomErrors to “off” to see full error. 

WS-14

Then modify Web.Config to set CustomErrors to “Off” and set Trust Level to “Full”. I put break points in the screenshot below to help you see them. You don’t need the breakpoints in the file.

WS-15

You can take care of the trust level problem if you modify the Web.Config in you SeverGenerated folder before deploying. Change to File view from Logical View > Show all files > ServerGenerated > open Web.Config > Add <trust level=”full” />

WS-17

For production (fully implemented) you will turn CustomErrors to “On” and create some custom error pages for certain conditions. Again, I am not a professional coder, so take my advice with a grain of salt.

So there you go….