问题
I have a working WCF service. I want to deploy it on Windows Azure. There Host Existing WCF Service On Azure it is written, that I should make right-click on the project and choose an option. But I don't have such an option in my menu. For which types of projects I can make such transitions with right-click mentioned above?
回答1:
First of all you have to check the project type in Visual Studio 2010. Please assure that the project you want to deploy is of type WCF Application or WebApplication (hosting the WCF service). If it is a Website project (hosting the WCF service) you can easily convert it from within Visual Studio to a WebApplication project.
If your project is a WCF library then you will have to host it first in a WCF application or WebApplication project before you can deploy it to Windows Azure (or even better host it directly in a Windows Azure WCFServiceRole or WebRole project).
Then you have to install the latest Windows Azure SDK so that all the Windows Azure features are installed on your development machine. And you should have the "Add Windows Azure Deployment Project" option.
To host the WCF library in a WCF Application do the following (should be nearly the same for the Windows Azure WCFServiceRole project):
In Visual Studio 2010, create a WCF Application project and add it to your solution.
Under the solution view of this new WCF Application project, add a reference to WCF Library by "References->Add References->Projects", or by "References->Add References->Browser" to its DLL.
Under the solution view of the new project, delete IService1.cs, also delete Service1.svc.cs under Service1.svc because we will use service implementation from the WCF library. But keep Service1.svc.
Under the solution view of the new project, double click Service1.svc to open it, replace its following marker line:
<%@ ServiceHost Language="C#" Debug="true" Service="WcfWebService.Service1"
CodeBehind="Service1.svc.cs" %>
with
<%@ ServiceHost Language="C#" Debug="true" Service="WcfServiceLibrary.Service1" %>
You might need to change WcfWebService, WcfServiceLibrary and Service1 and use your real names to make it work.
Please let me know if this was helpful.
来源:https://stackoverflow.com/questions/11065682/changing-existing-wcf-project-to-azure-project