0

I downloaded the getting started sample app from Azure Cosmos DB and am getting the following error with 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

And the code where it fails

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

Here's the packages.config: do I need to set a different targetFramework for Visual Studio Mac?

<?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>
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460
  • According to the packages.config, `Microsoft.Azure.DocumentDB` it is not the .netcore platform sdk, please have a try to use [Microsoft.Azure.DocumentDB.Core](https://www.nuget.org/packages/Microsoft.Azure.DocumentDB.Core/) SDK – Tom Sun - MSFT Jun 05 '17 at 09:57
  • Looks like I have to target .net core as my target framework to add the package - but I don't see the option for it in my target framework dropdown under project options - how do I enable that? – MonkeyBonkey Jun 05 '17 at 13:05
  • Would you mind sharing your demo code link? It seems that it is not a .net core project. About Azure documentdb .netcore please refer to the [document](https://learn.microsoft.com/en-us/azure/cosmos-db/documentdb-dotnetcore-get-started). – Tom Sun - MSFT Jun 06 '17 at 01:36
  • if you go to azure and click on new document db -> graph api -> getting started, it'll generate the project. It is not a core project. – MonkeyBonkey Jun 06 '17 at 14:55
  • We can create [.NET Core](https://www.microsoft.com/net/core/platform) apps that run on Windows, Linux and macOS. We also could get info about azure DocumentDB and .NET Core from the official [tutorials](https://learn.microsoft.com/en-us/azure/cosmos-db/documentdb-dotnetcore-get-started). – Tom Sun - MSFT Jun 07 '17 at 01:21

2 Answers2

0

I think Protocol.Tcp is not is .NET Core. Can you try using

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

or

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

Thanks!

0

According to your comment, you use .net project. Please don't try to run .net project on the MacOS. We can create .NET Core apps that run on Windows, Linux and macOS. We also could get info about azure DocumentDB and .NET Core from the official tutorials.

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • Is there a way to change the target to .net core? – MonkeyBonkey Jun 07 '17 at 14:56
  • Base on my knowledge, It is not make sense to do that. Because the code are depended on different libraries between .net project and .net core project. So the implement code may be different on 2 platform. – Tom Sun - MSFT Jun 08 '17 at 00:52