Forum Xamarin.iOS

Xamarin.Forms Error CS0246 'Foundation' could not be found

HannahCHannahC Member ✭✭

I've created an APP(Xamarin.forms) in Visual Studio 2017. I want to add wifi connection function into my iOS project (using NEHotspotConfigurationManager) and compile the following code on 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;
    }

Even though I can see "Add reference 'Xamarin.iOS.dll'" when I have a right-click on the red words, but it still appears three errors about Foundation, UIKit, and NetworkExtension not being found after I compiled the project.

   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?)

I check the 'Xamarin.iOS' in the reference list in iOS project(Modbusbutton3.iOS) with the version 0.0.0.0

However, the reference 'Xamarin.iOS' in the project(Modbusbutton3) is blank. I don't know whether it's related to my problem

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)"

What should I do with this problem?

Answers

Sign In or Register to comment.