错误CS0103:当前上下文中不存在名称“HttpClientFactory”

时间:2015-09-08 10:21:34

标签: c# mono debian-based xbuild

我正在尝试构建此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

使用mono进行构建:

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

试图建立这个项目:

$ 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

这是错误的,意思是:“错误CS0103:当前上下文中不存在名称'HttpClientFactory'”??

我可以谷歌,HttpClientFactory是名称空间System.Net.Http的一部分。几乎所有libmono-都安装在我的系统上。

编辑: 此外,我安装了Microsoft Visual Studio Community 2015 14.0.23107.0 D14REL,最新版本和错误是相同的。

EDIT2: 也许,我找到了解决方案。它是Visual Studio 2013,而不是2015年。我不知道它应该是哪种单声道,可能有一种降级有助于构建HttpClientFactory ...

1 个答案:

答案 0 :(得分:0)

将Nuget包Microsoft.AspNet.WebApi.Client降级到v5.2.2。 对我有用。