다음을 통해 공유


Hosting WCF/Workflow Service in IIS directly from Visual Studio 2010 and start debugging by just hitting F5 on Visual Studio.

 

Problem:

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'

Description: Machine generated alternative text: Edit Application Pool I ‘ ________ WorkflowService .NET framework version: Framework v4.0 30319 Managed pipelin e mode: Integrated w j start application pool immediately [ 0K ] [ Cancel j

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.) 

Description: Machine generated alternative text: Add Web Site site name: Application pool: ________________ WorkflowService WorkflowService [ Select... j Content Directory hysicaI path: Pass-through authentication [connect as... ] [Test Settings... j Binding ]ype: IP address: Port: [hap vj All Unassigned 80 Host name: localhost Example: www.contoso.com or marketing.contoso.com Start Web site immediately [ 0K j [ Cancel j

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.

Description: Machine generated alternative text: Add Site Binding I lype: net.tcp H ßinding information: 808:1 j OK ] [ Cancel j

Description: Machine generated alternative text: Site Bindings Type Host Name Port IP Address Binding Infor [ Add... j http localhost 80 * . net.tcp 808:* I _________________________________________________ ______________________________ Close

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'

Description: Machine generated alternative text: Advanced Settings [ ‘ _______ El (General) Application Pool Workflow5ervke Bindings httpr:8U:iocaihost,net.tcp:8Ur ID 3 I Name WorkflowService Physical Path D:\[earning\My Blog\Workflow hoste Physical Path Credentials Physical Path Credentials Logon 1 ClearText Start Automatically True Behavior Connection Limits Enabled Protocols http.net.tcp S Failed Request Tracing Name [name] A unique name for the site. OK Cancel

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.) 

Description: Machine generated alternative text: WorkflowService X WorkflowService.xamb Application Build ______ Web Package/Publish Web Package/Publish SQL Servers Silverlight Applications Build Events Resources Settings Reference Paths Signing Code Analysis WorkflowServicePinglm p. cs Configuration: L1A _______ Platform: [N/A ________ Start URL ! I Dont open a page. Wait for a request from an externat application. Rl apply server settings to all users (store in project file) Use Visual Studio Qevelopment Server ® , recific port [am Virtual path: L’ E NTLM Authentication fl Enable Edit and Continue ‘G’ Use Local US Web server Project Url: http:HlocalhostfWorkflowService [ Create Virtual Directorx] Override application root URL https://localhostfWorkflowService © Use Custom Web Server Server Url: L

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.