What steps do I need to take to convert from a class library to a WCF?

前端 未结 2 1180
我在风中等你
我在风中等你 2021-01-18 06:51

I created a project as a Class Library. Now I need to make it into a WCF. I can create a WCF project, but I would like to avoid all that fuss with TFS. I\'ve done the App.co

2条回答
  •  星月不相逢
    2021-01-18 07:22

    This is what I had to do to convert my class library to WCF REST application.

    1) Modify the .csproj file and add the below two lines to the first PropertyGroup element in .csproj file.

    {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
    false
    

    2) Add the following line to below to import Microsoft.WebApplication.targets file

    
    

    3) Add the following code to the end of the file before the tag.

    
    
      
        
          False
          True
          50178
          /
          
          
          False
          False
          
          
          False
        
      
    
    

    4) Save the .csproj file and Reload the project.

    5) Add a Web.Config file to the project and add the below bare minimal code. You can add more later per your requirement.

        
    
    
      
        
      
    
      
        
          
        
      
    
      
        
        
          
            
            
          
        
      
    
    
    

    6) Add a Global.asax file. Below is a sample file.

        public class Global : HttpApplication
    {
        void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes();
        }
    
        private void RegisterRoutes()
        {
            // Edit the base address of Service1 by replacing the "Service1" string below
            RouteTable.Routes.Add(new ServiceRoute("YourService", new WebServiceHostFactory(), typeof(YourServiceClass)));
        }
    }
    

    7) Finally in the project's properties, under Build tab, if the output path is set to bin\Debug modify it to bin\.

提交回复
热议问题