0

我从 Azure Cosmos DB 下载了入门示例应用程序,但在使用 Visual Studio Mac 时出现以下错误

System.TypeLoadException: Could not resolve type with token 010000f6 (from typeref, class/assembly System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
  at Microsoft.Azure.Documents.Client.DocumentClient.Initialize (System.Uri serviceEndpoint, Microsoft.Azure.Documents.Client.ConnectionPolicy connectionPolicy, System.Nullable`1[T] desiredConsistencyLevel) [0x00014] in <f7f11c3ada88490092c73d6bef54be97>:0
  at Microsoft.Azure.Documents.Client.DocumentClient..ctor (System.Uri serviceEndpoint, System.String authKeyOrResourceToken, Microsoft.Azure.Documents.Client.ConnectionPolicy connectionPolicy, System.Nullable`1[T] desiredConsistencyLevel) [0x00069] in <f7f11c3ada88490092c73d6bef54be97>:0
  at GraphGetStarted.Program.Main (System.String[] args) [0x00021] in /DocumentDB-Quickstart-DotNet-Graph/GraphGetStarted/Program.cs:29

以及失败的代码

   DocumentClient client = new DocumentClient(url, authKey, policy);

这是 packages.config:我需要为 Visual Studio Mac 设置不同的 targetFramework 吗?

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.Azure.DocumentDB" version="1.14.0" targetFramework="net452" />
  <package id="Microsoft.Azure.Graphs" version="0.2.0-preview" targetFramework="net452" />
  <package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net452" />
  <package id="Microsoft.CodeAnalysis.Common" version="1.3.0" targetFramework="net452" />
  <package id="Microsoft.CodeAnalysis.CSharp" version="1.3.0" targetFramework="net452" />
  <package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
  <package id="System.Collections" version="4.3.0" targetFramework="net452" />
  <package id="System.Collections.Immutable" version="1.1.37" targetFramework="net452" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net452" />
  <package id="System.Linq" version="4.3.0" targetFramework="net452" />
  <package id="System.Reflection.Metadata" version="1.2.0" targetFramework="net452" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net452" />
  <package id="System.Runtime" version="4.3.0" targetFramework="net452" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net452" />
  <package id="System.Threading" version="4.3.0" targetFramework="net452" />
</packages>
4

2 回答 2

0

根据您的评论,您使用 .net 项目。请不要尝试在 MacOS 上运行 .net 项目。我们可以创建在 Windows、Linux 和 macOS 上运行的.NET Core应用程序。我们还可以从官方教程中获取有关 azure DocumentDB 和 .NET Core 的信息。

于 2017-06-07T01:20:22.140 回答
0

我认为 Protocol.Tcp 不是 .NET Core。你可以尝试使用

新的 ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway, ConnectionProtocol = Protocol.Https }))

或者

新的 ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Https }))

谢谢!

于 2017-06-01T22:27:51.793 回答