Click here to Skip to main content
15,885,216 members
Articles / Desktop Programming / Windows Forms

Visual Application Launcher

Rate me:
Please Sign up or sign in to vote.
4.91/5 (37 votes)
23 Jan 2012CPOL23 min read 107K   3.7K   116  
A WinForms UI using WCF services, Entity Framework, repository data access, repository caching, Unit of Work, Dependency Injection, and every other buzz work you can think of!
--------Setting up VAL--------

There are a number of configuration settings you need to make before you can run the application. Please make sure you have completed
each step described here


--------DATA ACCESS--------

* In the database folder of the solution, find the file VAL.sql


Make sure you are happy with the paths for VAL here, they default to the install directory of SQL Server

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\VAL.mdf
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\VAL_1.ldf

If you keep your database files in a different location, modify the paths and save. 



* On the SQL Server where you want the database, execute the SQL file

You can do this easily from SQL Server Management Studio

* Connect to the server instance
* Choose File -> Open -> File
* Browse to and select VAL.Sql
* SQL will be opened in a new query window
* Click the 'Execute SQL' button
* Make sure there were no errors reported. 

Refresh your Management Studio windows, you should now see the VAL database in your explorer window


--IMPORTANT STEPS AFTER CREATING THE DATABASE--

YOU NEED TO DO ALL OF THESE!


**** The database script will have created a new login - VALUser. It will be DISABLED. 

Under security, find the login, highlight & choose Properties -> Status. Set to 'Enabled'. click OK



**** The database script generated a password for VALUser called 'ChangeThisPassword'

Change the password for VALUser. The default connection string in the database uses VALUser, but you can make this anything you like



**** Create a user record for the account you are going to use to run the application 

There needs to be a default record in the [Users] table that identifies the account you are going to run the application as. 

If you run without creating the user, and you will see an exception message saying 'User {0} does not exist in the VAL database.'

* In your SQL management window, open the users table
* Create a new record with the following values

* WindowsIdentityName - In UPPER CASE, enter the name of the account you sign on with, This will be the value returned by Environment.UserName.
* Forename \ Surname - Obvious...! 
* IsActive - Set to true
* Save the record

You will now be identified OK when running VAL. 



2) Hosting the WCF Services 

If you have an IIS Server you can use locally, I suggest you use these settings

* Create a virtual directory called VAL in your default web site. e.g. The url should be http://localhost/VAL
* Point the virtual directory at the \VAL.Service solution folder
* On the properties of the Virtual Directory...
    1) choose 'Directory Security' 
    2) Click on 'Edit' for 'Anonymous access and authentication'
    3) Untick'Anonymous Access'
    4) Tick 'Integrated Security'
    5) Click OK




** IMPORTANT **

You need to make sure that the the account running your IIS process (e.g. MACHINENAME\ASPNET) has Read permissions to the \VAL.Service solution folder 

If you run into problems testing the endpoints below, or see error messages such as this

[Failed to execute the request because the ASP.NET process identity does not have read permissions to the global assembly cache.] 

..then it's likely a permissions issue to your directory,



You should also be able to use the default Visual Studio web server, just configure it to use a specific Port number. This is so the endpoint values
refer to the same location!




3) Configuration Values

You'll need to make a few changes to both the Client application config and the Server 'Services' config. 

--------Client Config--------


1) Specifiy the endpoints for your WCF services. These default to localhost, which may be correct for you. E.g

http://localhost/VAL/UserService.svc

Make sure each of the endpoints is correct. You can test them by doing a Ctrl->Click over the values in visual studio, 
it should navigate you to the service page & display the 'This is a Windows� Communication Foundation service.' page



2) Make the following changes to the VAL custom section configuration values

These values are REQUIRED for normal application operation.

* microsoftOfficeLocation - The root location of MS Office. Will be something like C:\Program Files\Microsoft Office\

* administratorDomainGroup - IMPORTANT: This needs to be a group (either local or on the domain) that you are a member of. This is required for access to the admin screens



Some additonal values that are useful are

* activeDirectoryDomain - If you are on a domain, enter a valid LDAP string. e.g. "LDAP://MyDomain". This will be used when searching for users



The rest of the VAL settings are described within the code. Have a look at class VALElement in VAL.Common.Configuration 


--------Server Config--------


1) Specifiy the connection string for the entity framework. Put in whatever password you set for the VALUser account in the earlier step

2) Make sure all the service endpoints are correct for your environment. Should be OK with the 'localhost' defaults

3) Set the value for AppSetting 'AdministratorGroup'. This should be the same as the client value administratorDomainGroup.




--------First Run--------

When you first run the application, you'll see an exception about 'No file permissions for user'. This is expected because we haven't set any
up yet. Just continue running and assign some permissions to your account under the Admin screen




--GOTCHA's--

* Remember, there's caching using the ASP.Net web cache that lives on beyond the life of your application. If you make any manual
amendments to the VAL database, the cache won't invalidate & it will still return old data. 


Easiest thing to do is to reset the cache by running iisreset, or just recycle the application pool if you have App Pools available



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions