none
How to use .Net Framework command lines to implement the functionalities of "Add Service Reference" and "Update Service Reference" in Microsoft Visual Studio? RRS feed

  • Question

  • Recently we have developed a C# Project based on Microsoft Visual Studio 2017, for a customer, pending to connect to several service references by web sites provided by the customer.

    However, the customer does not allow us to install Visual Studio on their staging environment, but .Net Framework 4.x is installed instead. As a result, we will have to use .Net command line to do the following two jobs of Visual Studio:

    1. Add Service Reference. 
    2. Update Service Reference.

    The list of command lines of .Net Framework 4.0 is shown below:

    AddInProcess.exe
    AddInProcess32.exe
    AddInUtil.exe
    AppLaunch.exe
    aspnet_compiler.exe
    aspnet_regbrowsers.exe
    aspnet_regiis.exe
    aspnet_regsql.exe
    aspnet_state.exe
    aspnet_wp.exe
    CasPol.exe
    ComSvcConfig.exe
    csc.exe
    cvtres.exe
    DataSvcUtil.exe
    dfsvc.exe
    EdmGen.exe
    ilasm.exe
    InstallUtil.exe
    jsc.exe
    Microsoft.Workflow.Compiler.exe
    MSBuild.exe
    mscorsvw.exe
    ngen.exe
    ngentask.exe
    RegAsm.exe
    RegSvcs.exe
    ServiceModelReg.exe
    SMSvcHost.exe
    vbc.exe
    WsatConfig.exe

    We have explored all .Net Framework command lines, particularly csc.exe and msbuild.exe, but got no idea up to now.

    Can you please kindly show us how to use .Net Framework command lines to implement the above two functionalities?

    Thanks.

    Monday, February 17, 2020 2:34 AM

All replies

  • Hi BlueSky2020, 

    Welcome to MSDN forum.

    According to your description, please refer to the link to use the DataSvcUtil.exe.

    In addition, you could have a look at the similar issue to update service reference and hope it helps.

    Have a nice day.

    Best Regards,

    Anna


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, February 18, 2020 9:06 AM
  • Hi, Anna,

    First of all, thank you for the reply. 

    I tried the DataSvcUtil.exe command line, but unfortunately it could not work and failed in front of 3 different webservices. 

    The text output of running the DataSvcUtil.exe command line is shown below.

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    C:\Windows\Microsoft.NET\Framework\v4.0.30319>C:\Windows\Microsoft.NET\Framework\v4.0.30319\DataSvcUtil /out:"D:\Daniel\doc\CPF\Test\Test4\Connected Services\data.cs" /uri:"http://localhost/ClinicWebService/ClinicWebService.asmx"
    DataSvcUtil for Microsoft (R) .NET Framework version 4.8.3761.0
    Copyright (C) Microsoft Corporation. All rights reserved.

    Writing object layer file...
    error 7001: The remote server returned an error: (500) Internal Server Error.

    Generation Complete -- 1 errors, 0 warnings

    C:\Windows\Microsoft.NET\Framework\v4.0.30319>C:\Windows\Microsoft.NET\Framework\v4.0.30319\DataSvcUtil /out:"D:\Daniel\doc\CPF\Test\Test4\Connected Services\data.cs" /uri:"http://localhost/ClinicWebService/ClinicWebService.asmx"
    DataSvcUtil for Microsoft (R) .NET Framework version 4.8.3761.0
    Copyright (C) Microsoft Corporation. All rights reserved.

    Writing object layer file...
    error 7001: The remote server returned an error: (500) Internal Server Error.

    Generation Complete -- 1 errors, 0 warnings

    C:\Windows\Microsoft.NET\Framework\v4.0.30319>C:\Windows\Microsoft.NET\Framework\v4.0.30319\DataSvcUtil /out:"D:\Daniel\doc\CPF\Test\Test4\Connected Services\data.cs" /uri:"http://localhost/ClinicWebService/ClinicWebService.asmx"
    DataSvcUtil for Microsoft (R) .NET Framework version 4.8.3761.0
    Copyright (C) Microsoft Corporation. All rights reserved.

    Writing object layer file...
    error 7001: The remote server returned an error: (500) Internal Server Error.

    Generation Complete -- 1 errors, 0 warnings

    C:\Windows\Microsoft.NET\Framework\v4.0.30319>

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Do you have any further ideas or solutions to this issue?

    Thank you!


    Tuesday, February 25, 2020 8:31 AM
  • Hi, Anna,

    As per the svcutil.exe solution, I have also explored by creating a simple webservice, namely "HelloWorldWebApp", unfortunately it still cannot work under a command-line mode.

    Let me go through the details of my exploration.

    After creating the "HelloWorldWebApp" webservice, as a comparision, at first, I made an attempt to perform an "Add Web Service" operation to add the "HelloWorldWebApp" webservice into an .Net Console application from Microsoft Visual Studio 2017. The "Add Web Service" operation in Visual Studio can automatically create multiple "metadata files" under the subfolder \Connected Services\ (see the screenshot file https://onedrive.live.com/?cid=20F5837EC1E965B0&id=20F5837EC1E965B0%21117&parId=20F5837EC1E965B0%21116&o=OneUp). The list of those "metadata files" is show below:

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    configuration.svcinfo
    configuration91.svcinfo
    HelloWorldWebApp.disco
    HelloWorldWebApp.wsdl
    Reference.cs
    Reference.svcmap
    Test5.HelloWorldWebApp.HelloWorldResponse.datasource

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

    As to command line, I can use srcutil.exe tool to generate some source code and metadata files, but can only create nothing more than a .CS file, a config file a .wsdl file, totally 3 files (see the screenshot file https://onedrive.live.com/?cid=20F5837EC1E965B0&id=20F5837EC1E965B0%21119&parId=20F5837EC1E965B0%21116&o=OneUp). The generated two files are listed below:

    ===========================================

    HelloWorldWebApp.cs

    HelloWorldWebApp.wsdl

    output.config

    ===========================================

    The command line to download the above three files are listed below:

    The command line to download .cs file and .config file

    "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\svcutil.exe" /t:code http://localhost/HelloWorldWebApp/HelloWorldWebApp.asmx

    The command line to download metadata file (.wsdl)

    "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\svcutil.exe" /t:metadata http://localhost/HelloWorldWebApp/HelloWorldWebApp.asmx

    Based on the above three files, then I tried to build the entire C# console project by using msbuild command line, but failed, because all the way it failed to identify the name space of the added webservice. 

    The detailed output message of the "msbuild" command line is shown below:

    =====================================================================

    D:\Test\Test6>C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild .\Test6.csproj
    Microsoft (R) Build Engine version 4.8.3761.0
    [Microsoft .NET Framework, version 4.0.30319.42000]
    Copyright (C) Microsoft Corporation. All rights reserved.

    Build started 26/02/2020 14:17:34.
    Project "D:\Test\Test6\Test6.csproj" on node 1 (default targets).
    Project file contains ToolsVersion="15.0". This toolset may be unknown or missing, in which case you may b
    e able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced
     to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="4.0". Fo
    r more information, please see http://go.microsoft.com/fwlink/?LinkId=291333.
    GenerateTargetFrameworkMonikerAttribute:
    Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with res
    pect to the input files.
    CoreCompile:
      C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:a
      nycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Progr
      am Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Microsoft.CSharp.dll" /refe
      rence:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll
      " /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Syste
      m.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4
      .6.1\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsof
      t\Framework\.NETFramework\v4.6.1\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblie
      s\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" /reference:"C:\Program Files (x86)\Reference Asse
      mblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Net.Http.dll" /reference:"C:\Program Files (x86)\
      Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" /reference:"C:\Program Fil
      es (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.Linq.dll" /debug+ /deb
      ug:full /filealign:512 /optimize- /out:obj\Debug\Test6.exe /subsystemversion:6.00 /target:exe /utf8outpu
      t Test6.cs Properties\AssemblyInfo.cs "C:\Users\Daniel\AppData\Local\Temp\.NETFramework,Version=v4.6.1.A
      ssemblyAttributes.cs"
    Test6.cs(13,13): error CS0246: The type or namespace name 'HelloWorldWebApp' could not be found (are you m
    issing a using directive or an assembly reference?) [D:\Test\Test6\Test6.csproj]
    Test6.cs(13,72): error CS0246: The type or namespace name 'HelloWorldWebApp' could not be found (are you m
    issing a using directive or an assembly reference?) [D:\Test\Test6\Test6.csproj]
    Done Building Project "D:\Test\Test6\Test6.csproj" (default targets) -- FAILED.


    Build FAILED.

    "D:\Test\Test6\Test6.csproj" (default target) (1) ->
    (CoreCompile target) ->
      Test6.cs(13,13): error CS0246: The type or namespace name 'HelloWorldWebApp' could not be found (are you
     missing a using directive or an assembly reference?) [D:\Test\Test6\Test6.csproj]
      Test6.cs(13,72): error CS0246: The type or namespace name 'HelloWorldWebApp' could not be found (are you
     missing a using directive or an assembly reference?) [D:\Test\Test6\Test6.csproj]

        0 Warning(s)
        2 Error(s)

    Time Elapsed 00:00:00.22

    D:\Test\Test6>

    =====================================================================

    Anna, can you please try to help to pinpoint the issue? Is the failure due to the shortage of those multiple metadata files?

    Thank you for any further help!



    Wednesday, February 26, 2020 6:35 AM
  • Hi BlueSky2020,

    Thanks for your feedback and sorry for your delay reply.

    Based on my research, I suppose this errors are more about webservices, I suggest you could ask Stack Overflow tagged web-services forum for a better help.

    If you have any more .NET Framework Setup and Servicing issues in the future, please feel free to let us know.

    Sorry for any inconvenience and thanks for your understanding. 

    Best Regards,

    Anna


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com



    Wednesday, February 26, 2020 12:15 PM
  • "Project file contains ToolsVersion="15.0". This toolset may be unknown or missing"
    you are calling the wrong msbuild version.
    for a project created by VS 2017 you will need to call the one included with Visual Studio.

    "However, the customer does not allow us to install Visual Studio on their staging environment"
    But you are trying to build a C# project on the machine?
    Wednesday, February 26, 2020 5:01 PM