简体   繁体   English

Xamarin.Forms参考冲突

[英]Xamarin.Forms Reference conflict

My problem in Xamarin.Forms 我在Xamarin.Forms中的问题

i tried to use the class Reachability.cs from Xamarin (Downloaded from official source) used the check a url or ip address is reachable. 我尝试使用Xamarin的Reachability.cs类(从官方资源下载),用于检查url或ip地址是否可达。

When i try to build it shows me the following error message: 当我尝试构建时,显示以下错误消息:

Reference to type 'IPAddress' claims it is defined in 'System', but it could not be found 对类型“ IPAddress”的引用声称它是在“系统”中定义的,但找不到

I dont know how to solve it my usings are 我不知道如何解决我的用处

using System;
using SystemConfiguration;
using CoreFoundation;

在此处输入图片说明

Kind Regards, 亲切的问候,

Stefan 斯特凡

IPAddress is part of System.Net add IPAddress是System.Net添加的一部分

using System.Net;

to your usings - it' not listet in your question 与您的使用方式有关-它不在您的问题中

Check that the following assemblies are selected in your references (right click on references, edit references, all - I hope the names are correct as my xamarin studio is in german) 检查参考中是否选择了以下程序集(右键单击参考,编辑参考,全部-希望名称正确,因为我的xamarin Studio是德语的)

  • System 系统
  • System.Core 系统核心
  • System.Xml 系统文件
  • System.iOS 系统.iOS

Add the reachability.cs to your project 将reachability.cs添加到您的项目中

Add this lines to the c'tor or somewhere else in the class you want to use the reachability stuff 将此行添加到c'tor或您要使用可达性的类中的其他位置

UpdateStatus (null, null);
Reachability.ReachabilityChanged += UpdateStatus;

Add an eventhandler 添加事件处理程序

void UpdateStatus (object sender, EventArgs e)
    {
        Console.WriteLine(Reachability.RemoteHostStatus ().ToString());
        Console.WriteLine(Reachability.InternetConnectionStatus ().ToString());
        Console.WriteLine(Reachability.LocalWifiConnectionStatus ().ToString());

    }

Reachability.cs depends on System.Net classes which do not exist in PCL. Reachability.cs取决于PCL中不存在的System.Net类。 To test Reachability in Forms, use the Connectivity plugin instead. 要测试表单中的可达性,请改用Connectivity插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM