Xamarin not found - c#

I've been having issues with compiling code. The code was running successfully, and I uploaded it to Team Foundation Server. However, when people (including myself) downloaded the code from Team Foundation Server, the code produced the error:
"Error CS0246 The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?)"
I've got the newest version of Xamarin.Forms.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace XamlSamples
{
public class App : Application
{
public App()
{
// The root page of your application
MainPage = new HelloXamlPage();
}
};
}

Check whether you have enable automatic Package Restore (restore Xamarin.forms) in Visual Studio. Go to Tools--Options--Nuget Package Manager--General, check the items below:
Allow NuGet to download missing packages
Automatically check for missing packages during build in Visual Studio

Related

Algolia - Push Data

Following the example of how to push data to algolia, tried to connect only to Algolia with SearchClient, have installed the Algolia with .NET CLI (dotnet add package Algolia.Search) in VS Code.
The code is the follow:
using System;
using System.Threading.Tasks;
using Algolia.Search;
using System.Net.Http;
using Newtonsoft.Json.Linq;
namespace Example
{
class Program
{
static async Task Main(string[] args)
{
SearchClient client = new SearchClient("SUMI5AMP4H", "Admin API Key");
SearchIndex index = client.InitIndex("demo_ecommerce");
Console.WriteLine("Hello World!");
}
}
}
with command dotnet run
that returns:
Program.cs(13,13): error CS0246: The type or namespace name
'SearchClient' could not be found (are you missing a using directive
or an assembly reference?)
Program.cs(14,13): error CS0246: The type or namespace name
'SearchIndex' could not be found (are you missing a using directive or
an assembly reference?)
The project was created with dotnet new console
So having the Algolia.Search package installed how does it not recognize SearchClient and SearchIndex?
Was able to figure it out, needed to take look at the package of the Algolia.Search, so to find the location search for Algolia.Search.dll as defined in the project.assets.json.
The path is the follow C:\Users\{user}\.nuget\packages\algolia.search\6.3.0\lib\netstandard2.0 that where the package/dll is located now to see the code installed JetBrains dotPeek and opened the dll and search for SearchClient Class that was in Clients namespace.
So change using Algolia.Search; to using Algolia.Search.Clients; and already works and recognizes.
As you discovered, there was an issue with the provided snippet. I've just updated it and my colleagues deployed it. You should now see the correct snippets appear on the https://www.algolia.com/doc/onboarding/ page.
Thank you very much for letting us know.

The type or namespace name AsyncLocal<> could not be found

I am trying to integrate some code in my project. There is this AsyncLocal object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
...
private readonly AsyncLocal<bool> callbackExecutionInProgress;
Produces compiler error: Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'AsyncLocal<>' could not be found (are you missing a using directive or an assembly reference?). I have found nothing on google about this problem. According to Microsoft this should be defined in System.Threading, but referencing that namespace does not help.
Is there something else I have to do?
.Net = 4.7.02558
Problem fixed.
It was indeed the wrong version of the Framework. When I go in the menue bar to Help->About Microsoft Visual Studio, it says that .NET Framework version is 4.7.02558. But in the project file it said v4.5.2. This is somehow contradictory.
I changed the version to 4.6.1 now it works.

can't add System.Drawing.dll reference

Ok, so I'm on this bug for the last 4 hours and I dont know what to do..
I'm using Visual Studio Community 2017 and I opened Consol App(.net core) project. also I'm working on windows 8.1 OS.
I wanted to use Image from the System.Drawing namespace and it keeps giving me that error:
"the type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)"
I downloaded the System.Drawing.dll from https://www.dllme.com/dll/files/system_drawing_dll.html
(to the desktop) and then right click on the right project->add->Reference..->Browse..->System.Drawing.dll->OK
then I saw in the project (in the Solution Explorer) in the project dependencies->Assemblies->System.Drawing so I guess it works right?!
I'm still getting the same error and can't use the System.Drawing namespace, any suggestions?
using System;
using System.Net.Sockets;
using System.Drawing;
namespace client2
{
class Program
{
static void Main(string[] args)
{
try
{
//read image
Image image = new Image("C:\\image\\amir.jpg");
}
}
}
}
System.Drawing is not part of the cross-platform parts of .NET (Core). It depends on GDI+ which is part of Windows. There are plenty of alternatives out there.
Aside: Never download DLLs from an untrusted source.

Unity Hololens (UWP) build generates errors that Standalone builds do not?

Alternative titles:
Unity References Bug for Hololens Windows UWP Builds (10.0.10586.0)?
or..... Unity Hololens Builds have access to Standalone Build DLL references?
Quick pre-text: I'm designing an app to run on the Hololens. The game plays perfectly fine inside of Unity. It builds perfectly fine to the PC, Mac & Linux Standalone platforms without error.
However, errors from "missing" references arise when building to the Windows Store platform. (Missing is in quotes because I've thoroughly checked and rechecked that I'm using the right references and that they are located where they should be).
Initial error on trying to build is:
Error building Player because scripts had compiler errors
error: The type or namespace name 'FileSystemEventArgs' could not be found (are you missing a using directive or an assembly reference?)
private void PrototypeFileWatcher_Created(object sender, FileSystemEventArgs e)
{
...
}
When this error is corrected by commenting out the aforementioned function and associated code, and building is attempted again, these errors come forth:
error: The name 'Console' does not exist in the current context
catch (Exception e)
{
Console.WriteLine(e.Message);
}
error: Argument 1: cannot convert from 'string' to 'System.IO.Stream'
using (StreamReader sr = new StreamReader(path))
{
...
}
error: The type or namespace name 'BufferedStream' could not be found (are you missing a using directive or an assembly reference?)
using (BufferedStream bs0 = new BufferedStream(f0))
{
...
}
References are stored at the appropriate location:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Unity Full v3.5\System.Core.dll
References are listed in the heading of the scripts:
using UnityEngine;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Threading;
With all that said. I've tried:
-Changing Api Compatibility Level*
-Changing the project solutions net framework
-#if NETFX_CORE using x = WinRTLegacy.x; #else
-#if WINDOWS_UWP using System; #endif
-Trashing the project entirely and rebuilding from scratch
-And lots more
Struggling with this issue for over a full day now. I've NuGet pkgs, VS tools for Unity (otherwise known as VSTU), I'm using VS2015.
I'm at a complete loss right now. I'm not understanding if I can't build this to the Windows Store Platform as it can't use some of the DLLs that Unity standalone builds can?
HoloLens applications are constrained to using only what is a available in a UWP app. Some things will work in the Unity editor that do not work in a HoloLens Applications because the unity editor builds with mono instead of .net. You should constrain yourself to just things that work in UWP and they will work fine within the editor as well. Even the full set of UWP API's are not yet available to work with on HoloLens.
The full documentation for UWP is here:
https://learn.microsoft.com/en-us/uwp/api/
The subset added specifically for HoloLens is at the bottom of this page:
https://developer.microsoft.com/en-us/windows/mixed-reality/development
Unfortunately there isn't a place that highlights what isn't available. The Visual Studio compiler will help you understand what is there and what is not.

Why is System.Web.HttpUtility.UrlEncode giving namespace name doesn't exist in Visual C# 2008?

I'm trying to encode a URL using the HttpUtility.UrlEncode() method, why am I getting
The type or namespace name 'HttpUtility' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
error ?
I'm using Visual C# 2008, Express Edition.
The code I'm using is simplistic:
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Web;
namespace Lincr
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void cmdShorten_Click(object sender, EventArgs e)
{
WebRequest wrURL;
Stream objStream;
wrURL = WebRequest.Create("http://lin.cr?l=" + System.Web.HttpUtility.UrlEncode(txtURL.Text) + "&mode=api&full=1");
objStream = wrURL.GetResponse().GetResponseStream();
StreamReader objSReader = new StreamReader(objStream);
textBox1.Text = objSReader.ReadToEnd().ToString();
}
}
}
You need to include a reference to System.Web. Right-click your project in the Solution Explorer and choose Add Reference... . If you take a look at MSDN you'll see it's contained in the System.Web.dll assembly, as far as I remember, this is not referenced by default in new projects.
Just in case anyone stumbles across this, is running VS 2010 and cannot find System.Web in the available references...
Right click on the project and select Properties, if the Target Framework is set to ".Net Framework 4 Client" then change it to ".Net Framework 4".
But beware this will close, reopen and rebuild your project (also if you have a web service references these will need to be refreshed)
For people using .NET 4.0 or later, you can use WebUtility.UrlEncode which works with client profile (does not require System.Web assembly reference).
click on project tab in menu
click on Add References
in References window click on Framework and check the System.Web

Categories