简体   繁体   中英

error CS0103: The name `HttpClientFactory' does not exist in the current context

I'm trying to build this api_query https://github.com/CryptopiaNZ/CryptopiaApi-Csharp.git

$ uname -a
Linux kali 4.0.0-kali1-amd64 #1 SMP Debian 4.0.4-1+kali2 (2015-06-03) x86_64 GNU/Linux

Building with mono:

$ xbuild --version
XBuild Engine Version 12.0
Mono, Version 3.2.8.0
Copyright (C) 2005-2013 Various Mono authors

And trying to build this project:

$ xbuild CryptopiaApi.csproj
XBuild Engine Version 12.0
Mono, Version 3.2.8.0
Copyright (C) 2005-2013 Various Mono authors

Build started 08.09.2015 16:13:55.
__________________________________________________
Project "/usr/src/cryptopia/CryptopiaApi-Csharp/CryptopiaApi/CryptopiaApi/CryptopiaApi/CryptopiaApi.csproj" (default target(s)):
        Target PrepareForBuild:
                Configuration: Debug Platform: AnyCPU
        Target GenerateSatelliteAssemblies:
        No input files were specified for target GenerateSatelliteAssemblies, skipping.
        Target GenerateTargetFrameworkMonikerAttribute:
        Skipping target "GenerateTargetFrameworkMonikerAttribute" because its outputs are up-to-date.
        Target CoreCompile:
                Tool /usr/bin/mcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/CryptopiaApi.dll CryptopiaPrivateAPI.cs CryptopiaPublicAPI.cs DataObjects/Private/BalanceRequest.cs DataObjects/Private/BalanceResponse.cs DataObjects/Private/CancelTradeRequest.cs DataObjects/Private/CancelTradeResponse.cs DataObjects/Private/DepositAddressRequest.cs DataObjects/Private/DepositAddressResponse.cs DataObjects/Private/OpenOrdersRequest.cs DataObjects/Private/OpenOrdersResponse.cs DataObjects/Private/SubmitTipRequest.cs DataObjects/Private/SubmitTipResponse.cs DataObjects/Private/SubmitTradeRequest.cs DataObjects/Private/SubmitTradeResponse.cs DataObjects/Private/TradeHistoryRequest.cs DataObjects/Private/TradeHistoryResponse.cs DataObjects/Private/TransactionRequest.cs DataObjects/Private/TransactionResponse.cs DataObjects/Public/CurrenciesResponse.cs DataObjects/Public/MarketHistoryRequest.cs DataObjects/Public/MarketHistoryResponse.cs DataObjects/Public/MarketOrdersRequest.cs DataObjects/Public/MarketOrdersResponse.cs DataObjects/Public/MarketRequest.cs DataObjects/Public/MarketResponse.cs DataObjects/Public/MarketsRequest.cs DataObjects/Public/MarketsResponse.cs DataObjects/Public/TradePairsResponse.cs Implementation/AuthDelegatingHandler.cs Implementation/ICryptopiaApiPrivate.cs Implementation/ICryptopiaApiPublic.cs Implementation/IRequest.cs Implementation/IResponse.cs Implementation/PrivateApiCall.cs Implementation/PublicApiCall.cs Models/BalanceResult.cs Models/CurrencyResult.cs Models/MarketHistoryResult.cs Models/MarketOrderResult.cs Models/MarketOrdersResult.cs Models/MarketResult.cs Models/OpenOrderResult.cs Models/TradeHistoryResult.cs Models/TradePairResult.cs Models/TransactionResult.cs Properties/AssemblyInfo.cs /target:library /define:"DEBUG;TRACE" /reference:../packages/Newtonsoft.Json.7.0.1/lib/net45/Newtonsoft.Json.dll /reference:/usr/lib/mono/4.5/System.dll /reference:/usr/lib/mono/4.5/System.Net.dll /reference:/usr/lib/mono/4.5/System.Net.Http.dll /reference:/usr/lib/mono/4.5/System.Net.Http.Formatting.dll /reference:/usr/lib/mono/4.5/System.Web.dll /reference:/usr/lib/mono/4.5/System.Xml.Linq.dll /reference:/usr/lib/mono/4.5/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/4.5/Microsoft.CSharp.dll /reference:/usr/lib/mono/4.5/System.Data.dll /reference:/usr/lib/mono/4.5/System.Xml.dll /reference:/usr/lib/mono/4.5/System.Core.dll /warn:4
CryptopiaPrivateAPI.cs(23,14): error CS0103: The name `HttpClientFactory' does not exist in the current context
CryptopiaPublicAPI.cs(22,14): error CS0103: The name `HttpClientFactory' does not exist in the current context
CryptopiaPublicAPI.cs(70,11): error CS0433: The imported type `Newtonsoft.Json.Linq.JObject' is defined multiple times
                /usr/src/cryptopia/CryptopiaApi-Csharp/CryptopiaApi/CryptopiaApi/CryptopiaApi/../packages/Newtonsoft.Json.7.0.1/lib/net45/Newtonsoft.Json.dll (Location of the symbol related to previous error)
                /usr/lib/mono/4.5/System.Net.Http.Formatting.dll (Location of the symbol related to previous error)
        Task "Csc" execution -- FAILED
        Done building target "CoreCompile" in project "/usr/src/cryptopia/CryptopiaApi-Csharp/CryptopiaApi/CryptopiaApi/CryptopiaApi/CryptopiaApi.csproj".-- FAILED
Done building project "/usr/src/cryptopia/CryptopiaApi-Csharp/CryptopiaApi/CryptopiaApi/CryptopiaApi/CryptopiaApi.csproj".-- FAILED

Build FAILED.
Errors:

/usr/src/cryptopia/CryptopiaApi-Csharp/CryptopiaApi/CryptopiaApi/CryptopiaApi/CryptopiaApi.csproj (default targets) ->
/usr/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

        CryptopiaPrivateAPI.cs(23,14): error CS0103: The name `HttpClientFactory' does not exist in the current context
        CryptopiaPublicAPI.cs(22,14): error CS0103: The name `HttpClientFactory' does not exist in the current context
        CryptopiaPublicAPI.cs(70,11): error CS0433: The imported type `Newtonsoft.Json.Linq.JObject' is defined multiple times

         0 Warning(s)
         3 Error(s)

Time Elapsed 00:00:00.9231760

What does this err, means: "error CS0103: The name `HttpClientFactory' does not exist in the current context" ??

As I can google, HttpClientFactory is a part of namespace System.Net.Http which is included. Almost all of libmono- are installed on my system.

Edit: Moreover, I've installed Microsoft Visual Studio Community 2015 14.0.23107.0 D14REL, latest version and errors are the same.

Edit2: Probably, I've found the solution. It is Visual Studio 2013, not 2015. I do not know which mono shall it be, probably kind of downgrade would help to build HttpClientFactory...

Downgrade the Nuget package Microsoft.AspNet.WebApi.Client to v5.2.2. It's worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM