Off the Ridge Code Newsletter


All posts in "WCF"

How to build WCF server with Windows Forms client.

Published April 25, 2014 in WCF , Windows Forms - 1Comments

A while ago I wrote a sample project: a server application that accepts incoming trade information from several different brokers. It consists of central position server, client and broker simulator.
The server was implemented using WCF while both the client and broker simulator using Windows Forms.

It’s a good learning project for those interested in WCF.
The project was written and built using Visual Studio 2012
It uses WCF and as such the server (PositionServerHost) must be run with administrative privileges, i.e. run your Visual Studio as administrator.

1. Database
   a. I’ve used SQL Express 2012.
   b. In the Database folder under PositionServerDatabase.
      I’ve provided both the database itself that can be attached as well scripted database objects: tables, types and store procedures.
      i.e. the database can be either attached (Right-click on Databases in the Object Explorer and attach PositionServer.mdf)
      or execute the following from PositionServerDatabase
         1. [dbo].[OpenPositions].sql
2. [dbo].[InsertOpenPositions].sql
         3. [dbo].[UpdateOpenPositions].sql

2. To Run in Visual Studio 2012
   a. Open Solution PositionServer.sln
   b. Build
   c. Click Debug/Run

   The following projects should start automatically:
   1. PositionServerHost
   2. DemoClient
   3. BrokerSimulator

3. To Run Outside Visual Studio
   1. Nagivate to PositionServerPositionServerHostbinDebug , Right Click on BrokerSimulator.exe and run as Administrator
   2. Nagivate to  PositionServerDemoClientbinDebug ,     double click on DemoClient.exe
   3. Nagivate to  PositionServerBrokerSimulatorbinDebug ,dobule click on BrokerSimulator.exe

4. In the Demo Client click “Connect” button to connect to the server.
   The Broker Simulator connects automatically upon hitting “Start Simulator” button.

Here’s the project, enjoy!