ASP.NET 5 add WCF service reference

前端 未结 5 2055

In Visual Studio 2015 Preview (Pre Release), how can I add a service reference for a WCF service?

5条回答
  •  鱼传尺愫
    2020-12-01 06:02

    Edit: The new extension for adding a connected service as posted in other answers still did not work for me, but I found another working configuration, though it requires you don`t use dnxcore50:

    • Have a class library holding the service reference (choose a framework <= aspnet5 used one, e.g. dnx451)
    • Reference that one into your aspnet5 with right clicking on references (will create all the wrap stuff)
    • Have Service model and needed serialization dll in "framework" section of project.json (dnxcore need to be removed)

           "dnx451": {
             "dependencies": {
              "YourClassLibWillAppearHere": "1.0.0-*" // after you reference it
             },
             "frameworkAssemblies": {
              "System.ServiceModel": "4.0.0.0",
              "System.ServiceModel.Http": "4.0.0.0",
              "System.Runtime.Serialization": "4.0.0.0"
             }
           }   
      

    You should be able to do where u need it:

    using YourNameSpace.ServiceReference
    

    Old Answer:

    this worked for me:

    I followed both the instructions at the same time provided under known issues for beta4 (find in page "WCF") at this link:

    https://github.com/aspnet/Home/releases

    so my steps where:

    1. added service reference to another project (class library or windows 8.1 univ app as advised)
    2. copied the reference class to the ASP.NET 5 project
    3. copied the whole

      ...

      from app.config to web.config

    4. copied all those missing dependencies list from the link above in project.json, under common dependencies, leaving alone the specific frameworks ones (trying to reference the dotnet4.6 class library as an aspnet framework dependency gave many missing types in that framework)

    "dependencies": { >> here << }

    "frameworks": {
        "dnx451": { },
        "dnxcore50": { }
      }
    

提交回复
热议问题