简体   繁体   中英

Could not load file or assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies

I am currently working on a project using Visual studio 2017 on Mac. The application is a native C# Multiplatform app for iOS and android with Xamarin.

在此处输入图片说明

I am trying to interface with the CosmosDB database provided by Microsoft azure an am using the package Microsoft.Azure.DocumentDB installed through NuGet

When initializing my client the same way as the examples in the getting started tutorial using

new DocumentClient(new Uri(EndpointUrl), PrimaryKey);

However, internally, I get the exception

Could not load file or assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

在此处输入图片说明

I am new to visual studio and was wondering what could be causing this problem. another package installed is 'Microsoft.Azure.Devices' Do I have to add this package to add this dll to my references? If so where can I find it?

Here is the 'packages.config' file

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.Azure.Amqp" version="2.3.2" targetFramework="xamarinios10" />
  <package id="Microsoft.Azure.Devices" version="1.16.0" targetFramework="xamarinios10" />
  <package id="Microsoft.Azure.Devices.Shared" version="1.15.0" targetFramework="xamarinios10" />
  <package id="Microsoft.Azure.DocumentDB" version="1.22.0" targetFramework="xamarinios10" />
  <package id="Microsoft.CSharp" version="4.5.0" targetFramework="xamarinios10" />
  <package id="Microsoft.NETCore.Platforms" version="2.1.0" targetFramework="xamarinios10" />
  <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="xamarinios10" />
  <package id="NETStandard.Library" version="2.0.3" targetFramework="xamarinios10" />
  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="xamarinios10" />
  <package id="System.AppContext" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Collections" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.ComponentModel.TypeConverter" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Console" version="4.3.1" targetFramework="xamarinios10" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Globalization" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.IO" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.IO.FileSystem" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Linq" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Net.Http" version="4.3.3" targetFramework="xamarinios10" />
  <package id="System.Net.Primitives" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Net.Sockets" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Net.WebSockets.Client" version="4.3.2" targetFramework="xamarinios10" />
  <package id="System.ObjectModel" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Reflection" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Runtime" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Runtime.Handles" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Runtime.Serialization.Formatters" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="xamarinios10" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="xamarinios10" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Threading" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Threading.Timer" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="xamarinios10" />
  <package id="System.Xml.XDocument" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="xamarinios10" />
  <package id="System.Configuration.ConfigurationManager" version="4.5.0" targetFramework="xamarinios10" />
  <package id="System.Security.AccessControl" version="4.5.0" targetFramework="xamarinios10" />
  <package id="System.Security.Permissions" version="4.5.0" targetFramework="xamarinios10" />
  <package id="System.Security.Principal.Windows" version="4.5.0" targetFramework="xamarinios10" />
</packages>

It turns out that Microsoft.Azure.DocumentDB is not compatible with Xamarin. Everything works fine if instead we use Microsoft.Azure.DocumentDB.Core

As Jason said, you could try to install System.Configuration.ConfigurationManager to ensure Configuration contain ConfigurationManager attrribute.

If you are using VS for Mac then currently you will need to add one PackageReference into the .csproj manually by using a text editor.

<ItemGroup>
    <PackageReference Include="Xamarin.Forms" Version="2.4.0.280" />
</ItemGroup>

For more details, you could refer to this discussion .

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