![](/img/trans.png)
[英]error CS0246: The type or namespace name 'KustoConnectionStringBuilder' could not be found
[英]Xamarin.Forms Error CS0246 'Foundation' could not be found
我在 Visual Studio 2017 中創建了一個 APP(Xamarin.forms)。我想將 wifi 連接 function 添加到我的 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、NetworkExtension三個錯誤。
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?)
我在 iOS 項目(Modbusbutton3.iOS)的參考列表中檢查了“Xamarin.iOS”,版本為 0.0.0.0在此處輸入圖像描述
但是,項目(Modbusbutton3)中的引用“Xamarin.iOS”是空白的。 我不知道這是否與我的問題有關在此處輸入圖像描述
I found that the reference 'Xamarin.iOS' in the project(Modbusbutton3) showed a red error with "Assembly not found for framework .NET Protable Subset (.NET Framework 4.5, Windows 8, Windows Phone 8.1, Windows Phone Silverlight 8)" enter圖片說明在這里
這個問題我該怎么辦?
您嘗試做的問題是,您需要了解關注點/抽象是分離的。 核心項目被 Android 和 iOS 項目引用,但 Android 和 Z1BDF605991920DB11CBDF8508 項目沒有被核心項目引用EBZ 示意性地,
Core-->Android & Core-->iOS
但Core<-x-Android, Core<-x-iOS
這是設計使然,即使您可以讓它做您正在嘗試的事情,但您不應該這樣做。
我們知道 iOS 和 Android SDK 非常不同。 因此,為了執行 wifi 連接功能(NEHotspotConfigurationManager),您必須在下面執行不同的功能。 您共享的代碼是僅為 iOS 本地檢索路徑/文件名的正確方法。
為了使其正常工作,還有許多其他方法可以做到這一點,如此處的官方Microsoft 文檔中所示。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.