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
enter image description here
However, the reference 'Xamarin.iOS' in the project(Modbusbutton3) is blank. I don't know whether it's related to my problem
enter image description here
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 image description here
What should I do with this problem?
The problem with what you are trying to do is that, you need to understand that there is a separation of concerns/abstraction. The Core project is referenced by the Android & iOS projects, but the Android & iOS projects are not referenced by the Core project. Schematically,
Core-->Android & Core-->iOS but
Core<-x-Android, Core<-x-iOS
This is by design, and even though you can make it do what you are trying, you shouldn't.
We know that the iOS & Android SDKs are very different. So in order to perform wifi connection functionality (NEHotspotConfigurationManager), you have to perform different functions underneath. And the code that you shared is the correct way of retrieving the path/file name natively ONLY for iOS.
In order to make it work, there's also many other ways of doing this as shown in the official Microsoft docs here.
Related
I am in the process of migrating an C# automation solution from .NET4.7.2 to .netCore. I am getting this error and I am not sure how to resolve it.
Issue :
if(!scenarioContext.ScenarioContainer.Resolve<Microsoft.VisualStudio.TestTools.UnitTesting.TestContext>().TestName.Contains("text")) { //code }
Error is given on the Microsoft.VisualStudio.TestTools.UnitTesting.TestContext>().TestName
Error : Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'TestTools' does not exist in the namespace 'Microsoft.VisualStudio' (are you missing an assembly reference?).
Managed to resolve it by adding MSTest Nuget packet
I am trying to include Google speech api in my unity app.
I have followed all the steps in the api documentation for c# https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries#client-libraries-install-csharp . I installed this package "Install-Package Google.Cloud.Speech.V1 -Pre" through NuGet package manager but no google references are being shown. This results to the error "The type or namespace name 'Google' could not be found (are you missing a using directive or an assembly reference?)". I checked these possible duplicates but to no avail "The type or namespace name 'Google' could not be found", "The type or namespace could not be found". Switching platform within unity from android to windows shows the google references but without resolving the error.
using Google.Cloud.Speech.V1;
using System;
namespace GoogleCloudSamples
{
public class SpeechGoogle
{
public static void Main(string[] args)
{
var speech = SpeechClient.Create();
var response = speech.Recognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 16000,
LanguageCode = "en",
}, RecognitionAudio.FromFile("audio.raw"));
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
Console.WriteLine(alternative.Transcript);
}
}
}
}
}
The error occurs from the first code line "using Google.Cloud.Speech.V1;". Is it possible that unity cannot support google cloud services or am I missing a step?
No, we don't support Unity (or Xamarin) in any of the Google Cloud Client Libraries.
Our supported platforms documentation. It's possible that the REST-based libraries can work on Unity, but we don't support that, and in particular the auth aspects are very likely to fail or require custom code.
To be clear, we'd like to support more platforms, but there's a pretty significant human cost involved in doing so, particularly for gRPC-based libraries where there's a native code component, and also particularly in terms of testing across a whole bunch of client platforms and Unity versions.
I am trying to make my C++ application cross platform and port it from MFC. The code base should be pretty portable but I am having problems getting something that works well. Xamarin looks promising it seems like I could put my C++ code into a library and call it from C# code but so far I can’t even get the most basic wizard created project to compile.
I am on a windows 7 machine. I did a fresh install of visual studio 2017 community. I installed what I think are the correct components (see below) and had the wizard create a simple project. It then generates a long list of cryptic error messages. I am afraid I am not a C# programmer (if this looks promising I will have a reason to learn it). I have had some java android experience with android studio but never done NDK. So these are Greek to me and my web searches have not been fruitful.
Does anyone have any idea what these messages mean?
In the wizard I made these choices:
1) Visual C# Android
2) Android app (Xamarain)
3) Single view app
4) Android 5.0 lolypop
And I got these error messages, without adding a line of my own code:
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Support' does not exist in the namespace 'Android' (are you missing an assembly reference?) App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 21 Active
Error CS0234 The type or namespace name 'Support' does not exist in the namespace 'Android' (are you missing an assembly reference?) App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 5 Active
Error CS0234 The type or namespace name 'Support' does not exist in the namespace 'Android' (are you missing an assembly reference?) App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 6 Active
Error CS0246 The type or namespace name 'AppCompatActivity' could not be found (are you missing a using directive or an assembly reference?) App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 13 Active
Error CS0115 'MainActivity.OnCreate(Bundle)': no suitable method found to override App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 16 Active
Error CS0115 'MainActivity.OnCreateOptionsMenu(IMenu)': no suitable method found to override App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 28 Active
Error CS0115 'MainActivity.OnOptionsItemSelected(IMenuItem)': no suitable method found to override App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 34 Active
Error CS0103 The name 'SetContentView' does not exist in the current context App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 19 Active
Error CS0103 The name 'FindViewById' does not exist in the current context App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 21 Active
Error CS0234 The type or namespace name 'Support' does not exist in the namespace 'Android' (are you missing an assembly reference?) App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 21 Active
Error CS0103 The name 'SetSupportActionBar' does not exist in the current context App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 22 Active
Error CS0246 The type or namespace name 'FloatingActionButton' could not be found (are you missing a using directive or an assembly reference?) App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 24 Active
Error CS0103 The name 'FindViewById' does not exist in the current context App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 24 Active
Error CS0246 The type or namespace name 'FloatingActionButton' could not be found (are you missing a using directive or an assembly reference?) App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 24 Active
Error CS0120 An object reference is required for the non-static field, method, or property 'MenuInflater.Inflate(int, IMenu)' App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 30 Active
Error CS0103 The name 'Snackbar' does not exist in the current context App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 48 Active
Error CS0103 The name 'Snackbar' does not exist in the current context App1 C:\Users\Andre\source\repos\App1\App1\MainActivity.cs 48 Active
Error NU1101 Unable to find package Xamarin.Android.Support.Design. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages App1 C:\Users\Andre\source\repos\App1\App1\App1.csproj 1
I had android NDK (R15C) selected as well as Apache Ant (1.9.3) and C++ Android development tools
I did not select the emulator as I want to use my phone at this point. I also left out the other NDK versions. Do these correspond to the android version eg 5.0 lolypop?
Thanks in advance.
Last time, I upgraded VS & try test a xamarin app, I also faced this error. I goto Tools -> NuGet Package Manager -> Package Manager Settings.
Check : Allow NuGet to download missing packages.
Check : Automatically check for missing packages during build in Visual Studio.
Then I rebuild app, NuGet check and download missing packages and build passed
I tried to understand this tutorial: http://odata.github.io/odata.net/#OData-Client-Code-Generation-Tool
I can generate the proxy without any problems. Just as it is described.
But at chapter "Consume the OData service" it doesn't work. I have named the application and the proxy exactly as shown in the tutorial. How can I make odata available in namespace Microsoft?
Screenshot
Error CS0234 The type or namespace name 'OData' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) TrippinApp C:\TrippinApp\Program.cs 6 Active
Error CS0246 The type or namespace name 'DefaultContainer' could not be found (are you missing a using directive or an assembly reference?) TrippinApp C:\TrippinApp\Program.cs 16 Active
Error CS0246 The type or namespace name 'DefaultContainer' could not be found (are you missing a using directive or an assembly reference?) TrippinApp C:\TrippinApp\Program.cs 16 Active
I used:
Microsoft Visual Studio 2017 (Trial)
Microsoft.Data.Edm v5.8.3
Microsoft.Data.Odata v5.8.3
Microsoft.Data.Services.Client v5.8.3
System.Spatial v.5.8.3
WCF Data Services 5.6 Tools (are installed)
continuation:
#Evandro Paula:Thank you for your help! I have come a little further thanks to your help. But unfortunately I have not come to the goal yet.
I installed/updated:
Microsoft Visual Studio 2017 (15.7.1) (Trial)
Microsoft.Data.Edm v5.8.3 (I have not found a more recent one)
Microsoft.Data.Odata v5.8.3 (I have not found a more recent one)
Microsoft.Data.Services.Client v5.8.3 (I have not found a more recent one)
Microsoft.OData.Client v7.4.4 (installed)
Microsoft.OData.Core v7.4.4 (installed)
Microsoft.OData.Edm v7.4.4 (installed)
Microsoft.Spatial v7.4.4 (installed)
System.Spatial v.5.8.3 (I have not found a more recent one)
WCF Data Services 5.6 Tools (are installed)
Screenshot of NuGet
Now the results look like this:
Compiling works with Proxy (TrippinProxy.cs), but without Odata example. (Screenshot)
As soon as I copy the code from the tutorial, compiling does't work anymore. (Screenshot)
using System;
using Microsoft.OData.SampleService.Models.TripPin;
namespace TrippinApp
{
class Program
{
static void Main(string[] args)
{
DefaultContainer dsc = new DefaultContainer(
new Uri("http://services.odata.org/V4/(S(fgov00tcpdbmkztpexfg24id))/TrippinServiceRW/"));
var me = dsc.Me.GetValue();
Console.WriteLine(me.UserName);
}
}
}
source: http://odata.github.io/odata.net/#OData-Client-Code-Generation-Tool
Now the Namespace Microsoft.OData is found. But not Microsoft.OData.SampleService (Screenshot)
I need a little example. How can I initialize the proxy and add a product (CreateProduct)? Or how can I get the example from the tutorial up and running?
First, update the packages you mentioned on your question to their latest version. It looks like Visual Studio didn't use the latest version in your case. I'm using Visual Studio 2017 Enterprise Edition (version 15.7.3) for this test.
Microsoft.OData.Client (version 7.4.4)
Microsoft.OData.Core (version 7.4.4)
Microsoft.OData.Edm (version 7.4.4)
Microsoft.Spatial (version 7.4.4)
Once the packages are up to date, you will observe the following build error, which is related to issue https://github.com/OData/lab/issues/80:
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'EdmxReader' does not exist in the namespace 'Microsoft.OData.Edm.Csdl' (are you missing an assembly reference?) ODataClient C:\temp\NET\ODataClient\Connected Services\TrippingService\TrippingProxy.cs 510 Active
The resolution for this issue is available at https://github.com/juliopinto15/lab/commit/deb1254301a775eb6771b0bed672dd3f56f37cfe.
Just change the proxy (e.g. TrippingProxy.cs) generated code line below as part of method LoadModelFromString():
return global::Microsoft.OData.Edm.Csdl.EdmxReader.Parse(reader);
to
return global::Microsoft.OData.Edm.Csdl.CsdlReader.Parse(reader);
In my case, I deleted the NuGet cache folder, and it compiles now.
%LOCALAPPDATA%\Nuget\v3-cache
I worked with the same example (TripPinService) and got the same error. It looks like there is an error in the sample.
Instead of:
var context = new DefaultContainer(new Uri(serviceRoot));
You need to write:
var context = new Default.Container(new Uri(serviceRoot));
After that code runs without errors
I'm following tutorial, installed RanvenDB embeeded and write:
public static IDocumentStore archives =
new EmbeddableDocumentStore { DataDirectory = "~/DataStore" };
then I let VS to find where is EmbeddableDocumentStore so and I add:
using Raven.Client.Embedded;
No errors yet and everything looks fine. Then I build:
Archives.cs(10,20): error CS0234: The type or namespace name
'Embedded' does not exist in the namespace 'Raven.Client' (are you
missing an assembly reference?)
Compile complete -- 1 errors, 0 warnings
And now it's error and there is no Embedded...
If I remove package.config and run install Ravendb Embedded again it will become green (with no errors) again but just after I run build...
How to repair it?
(tested different version : same result)
Make sure that you are building for the FULL .NET framework, and not just the client profile.