When you develop a WCF/Workflow service using Visual Studio and try to run it, by default Visual Studio runs it under web development server. Here the problem is that the web development server is a light weight host and does not support reach features which comes with IIS. For example web development server does not allow you to run a WCF/Workflow service, which is configured to use NET TCP binding. There are many more such features which do not come with web development server.
As a developer we all want to, just hit the F5 button and start debugging. But if your WCF/Workflow service is configured in such a way that it can only run under IIS, it becomes really tricky to start debugging it.
The common approach we generally follow is to out in which w3wp.exe our service is running and then attach the Visual Studio to that process.
In following text, I have shown another approach in which Visual Studio can be configured to run together with IIS. With this configuration your WCF/Workflow Services runs under IIS as soon you hit the F5 and you can start debugging without any hassles.
1. Create WCF/Workflow server. See how to create basic Workflow WCF Server.
2. Configure IIS to host your WCF/Workflow service.
(Note: -You can skip following steps if you already have some IIS website configured on port 80 and NET
TCP binding is configured. )
a. Open IIS Manager.
b. Add new application pool.
i. Select ‘Application Pools’ node from the left hand side tree view.
ii. Click on ‘Add Application Pool’ link from ‘Actions’ panel at right hand side.
iii. Give some name to your application pool. I have given name as ‘WorkflowService’. In below steps I will refer your application pool as ‘WorkflowService’.
iv. Change .Net Framework Version to 4.0
v. Click ‘Ok’
c. Add new ‘Web Site Application’ for your services.
i. Select ‘Sites’ node from the left hand side tree view.
ii. Right click on ‘Sites’ node and click ‘Add Web Site’
iii. Give Some name to your Web Site. I have given name as ‘WorkflowService’. I have given name as ‘WorkflowService’. In below steps I will refer your website as ‘WorkflowService’.
iv. Change Application Pool name to ‘WorkflowService’.
v. Provide some directory path to create IIS virtual directory for this new web site.
vi. Provide host name as ‘localhost’
vii. Click ‘Ok’
(Note : While clicking on Ok button you might get a message saying that some other website is already configured to run on port number 80. You just need to close that website and start your newly created website.)
d. Configure NET TCP Binding
i. Right click on ‘WorkflowService ‘ web site and click on ‘Edit Bindings’ to open ‘Site Bindings’ dialog.
ii. Click on ‘Add’ button to open ‘Add Site Binding’ dialog.
iii. From ‘Type’ dropdown select ‘net.tcp’.
iv. Type 808:* in Binding Information text box.
v. Click Ok.
e. Enable NET TCP Binding on Web Site.
i. Select ‘WorkflowService’ website node from left hand side tree view.
ii. Click on ‘Advanced Settings’ from ‘Actions’ panel at right hand side.
iii. Update ‘Enabled Protocols’ field by adding comma delimited value as ‘net.tcp’ at the end of the existing value.
iv. Click ‘Ok’
3. Configure Visual Studio Project settings to use IIS as service host instead of default web development server.
a. Select your service project in Solution Explorer and press ALT+ENTER to open project properties dialog.
b. Click on ‘Web’ tab on project properties dialog.
c. On ‘Web’ tab page, select ‘Use local IIS Web Server’ radio button.
d. Click on ‘Create Virtual Directory’ button to link your website project with IIS.
(Note: This step will fail if Visual Studio is not running in Administrator privileges.)
At this stage you have successfully configured IIS and Visual Studio to work together and help you debugging your WCF/Workflow services by just hitting on F5 button on Visual Studio.