【发布时间】:2020-04-23 04:07:44
【问题描述】:
我在 Visual Studio 2017 中创建了一个 APP(Xamarin.forms)。 我想将wifi连接功能添加到我的iOS项目中(使用NEHotspotConfigurationManager)并在Mac上编译以下代码:
bool success = await UIApplication.SharedApplication.OpenUrlAsync(
NSUrl.FromString(UIApplication.OpenSettingsUrlString), options: new UIApplicationOpenUrlOptions());
var config = new NEHotspotConfiguration(ssid, password, isWep: false);
config.JoinOnce = false;
var tcs = new TaskCompletionSource<NSError>();
NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(config, err => tcs.SetResult(err));
var error = await tcs.Task;
if (error != null)
{
var alert = new UIAlertController
{
Title = "Error",
Message = error.Description
};
alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
PresentViewController(alert, true, null);
return;
}
虽然我在红字上右击可以看到“Add reference 'Xamarin.iOS.dll'”,但是编译后还是出现Foundation, UIKit, and NetworkExtension not found三个错误该项目。
Error CS0246 The type or namespace name 'Foundation' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'UIKit' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'NetworkExtension' could not be found (are you missing a using directive or an assembly reference?)
我在版本 0.0.0.0 的 iOS 项目 (Modbusbutton3.iOS) 的参考列表中检查了“Xamarin.iOS” enter image description here
但是,项目 (Modbusbutton3) 中的引用“Xamarin.iOS”为空白。不知道是不是和我的问题有关 enter image description here
我发现项目中的引用“Xamarin.iOS”(Modbusbutton3)显示红色错误 “未找到框架 .NET Protable 子集(.NET Framework 4.5、Windows 8、Windows Phone 8.1、Windows Phone Silverlight 8)的程序集” enter image description here
这个问题我该怎么办?
【问题讨论】:
-
您使用的是最新的 VS for Mac 吗?在 Visual-Studio for Mac 中未正确引用您的 Xamarin.iOS。
标签: c# xamarin xamarin.forms xamarin.ios visual-studio-mac