使用Xamarin.Forms连接DB问题C#



我有以下内容:

MongoClientSettings settings = new MongoClientSettings();
settings.Server = new MongoServerAddress("localhost", 27017);
var client = new MongoClient(settings);

,在最后一行,我得到了:

{System.EntryPointNotFoundException: mono_get_runtime_build_info
  at (wrapper managed-to-native)** System.Runtime.InteropServices.RuntimeInformation:mono_get_runtime_build_info ()
  at System.Runtime.InteropServices.RuntimeInformation.get_FrameworkDescription () [0x00000] in <faa8163a322d41a99fc85eb6d1c29040>:0 
  at MongoDB.Driver.Core.Connections.ClientDocumentHelper.GetPlatformString () [0x00000] in <077b2160c936411eb67f8073bdcbbe94>:0 
  at System.Lazy`1[T].CreateValue () [0x00081] in <d18287e1d683419a8ec3216fd78947b9>:0 
  at System.Lazy`1[T].LazyInitValue () [0x00080] in <d18287e1d683419a8ec3216fd78947b9>:0 
  at System.Lazy`1[T].get_Value () [0x0003a] in <d18287e1d683419a8ec3216fd78947b9>:0 
  at MongoDB.Driver.Core.Connections.ClientDocumentHelper.CreateClientDocument (System.String applicationName) [0x00015] in <077b2160c936411eb67f8073bdcbbe94>:0 
  at MongoDB.Driver.Core.Connections.ConnectionInitializer..ctor (System.String applicationName) [0x00006] in <077b2160c936411eb67f8073bdcbbe94>:0 
  at MongoDB.Driver.Core.Connections.BinaryConnectionFactory..ctor (MongoDB.Driver.Core.Configuration.ConnectionSettings settings, MongoDB.Driver.Core.Connections.IStreamFactory streamFactory, MongoDB.Driver.Core.Events.IEventSubscriber eventSubscriber) [0x00040] in <077b2160c936411eb67f8073bdcbbe94>:0 
  at MongoDB.Driver.Core.Configuration.ClusterBuilder.BuildCluster () [0x0002e] in <077b2160c936411eb67f8073bdcbbe94>:0 
  at MongoDB.Driver.ClusterRegistry.CreateCluster (MongoDB.Driver.ClusterKey clusterKey) [0x000ad] in <42bdb488f5094fc1bb90030259d358c6>:0 
  at MongoDB.Driver.ClusterRegistry.GetOrCreateCluster (MongoDB.Driver.ClusterKey clusterKey) [0x00021] in <42bdb488f5094fc1bb90030259d358c6>:0 
  at MongoDB.Driver.MongoClient..ctor (MongoDB.Driver.MongoClientSettings settings) [0x0002d] in <42bdb488f5094fc1bb90030259d358c6>:0 
  at .....ctor () [0x00025] in ...

我尝试在此线路上进行连接:

var client = new MongoClient(settings);

没有设置,没有连接字符串,但没有...我能够使用命令提示和db.movie.insert添加文档https://www.tutorialspoint.com/mongodb/mongodb_create_database.htm,但是当我尝试使用C#驱动程序连接时,就像服务器未运行一样。

请帮忙!谢谢

尝试使用机器的IP,这是Mongo DB的主机。但是我建议您开发一些服务器端代码,例如使用节点JS。然后将基于REST的请求发送到您的节点JS应用程序,并在节点JS中将/从/写入/写入DB。这远胜于您在这里实现的目标。您的方法使您的数据处于危险之中。

最新更新