How to use c# 6 compiler in visual studio 2012 - visual-studio

Can any one help me how I can use the C#6 compiler in my project?
This is what I already tried:
I have installed the nuget package via this command:
Install-Package Microsoft.Net.Compilers
After that I am getting the below error:
"Error 1 The name 'nameOf' does not exist in the current context"
And when I try to change the compiler version in visual studio, C# 6 is not even showing up:

You can't. If you want to use C# 6.0 in Visual Studio, you will need to upgrade to VS 2015.

There is no nameOf keyword in C#. If this is the exact error message, you have a typo and should use nameof instead.

using System;
using System.Linq.Expressions;
public static String nameof<T>(Expression<Func<T>> name)
{
MemberExpression expressionBody = (MemberExpression)name.Body;
return expressionBody.Member.Name;
}
Use this. This is copied from another stackoverflow question

Related

Unable to use WifiNetworkSpecifier in Xamarin

I tried to use following code snippet in my XAMARIN project using Visual Studio (Windows 10, Android platform API 29).
WifiNetworkSpecifier.Builder builder = new WifiNetworkSpecifier.Builder();
But looks like "WifiNetworkSpecifier" is not available for Visual Studio.
Error: CS0246 The type or namespace name 'WifiNetworkSpecifier' could not be found (are you missing a using directive or an assembly reference?)
Please share workaround to resolve this issue.
VERSION DETAILS ARE AS FOLLOWS:
Microsoft Visual Studio Community 2019, Version 16.6.2
Xamarin.Android SDK 10.3.1.4 (d16-6/3a10de9).
First, right click Android project => Property => Application and choose the Target Framework to Android 10.0(Q) or higher:
Then in your project, reference the namespace:
using Android.Net.Wifi;
Then you can use WifiNetworkSpecifier in your project:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
WifiNetworkSpecifier.Builder builder = new WifiNetworkSpecifier.Builder();
}
you need to specify the namespace
using Android.Net.Wifi;
is VS, right clicking on the line that has the error should offer you a prompt to automatically suggest potential fixes

Compilation error on new Xamarin Forms project

I have installed Visual Studio for Mac (7.0.1 build 24 Community Edition), generated a new project using Forms, and could not get it to compile. The error shown makes no sense to me since the code looks correct.
I have not made any change to the code. It is as generated by the Wizard.
I have tried the following ways of setting up, on different machines:
Using Home Brew
Using the Visual Studio For Mac installer
Any pointers on how to work around this one will help.
Please look below Error Message
You cannot have a dash in your namespace. Try using TestAppXamarin or TestApp.Xamarin instead:
namespace TestApp.Xamarin {
public class TestAppClass { }
}

Visual Studio 2010 with MVC 4

I just downloaded and installed MVC 4 on VS 2010 Professional. I started a new project and here's the list of Errors that i got on my first build-
1.The type or namespace 'Infrastructure' does not exist in the namespace 'System.data.Entity'(Are you missing an assembly reference?)
2.Namespace 'schema' does not exist in namespace 'System.componentmodel.dataannotations'..
similar is the case with 'dbcontext','dbset','tablettribute','table','databasegeneratedattribute' .....
Please suggest what references do i need to include for these errors.?
How can i include the entity framework to my project as it says that it cannot be found?
This is the first time i am using ASP.NET MVC 4 with VS 2010.
I googled but didnt find the exact solution for this.
Please help!
regards
you don't have install Entity Framework thats y you got that type of error
you can solve this problem by do this
open Vs 2010
go to tools
select Library Package Manager
Go to Manage NUget Packages or Package Manager Console
if you use Package Manager Console type this command on console
Install-Package Entity-Framework
if you use Manage NUget Packages
Download EF5 and install it

Installed the reference from NuGet but VS2010 cant find the namespace

I am quite new to C# and Visual Studio but I just downloaded the Facebook C# SDK from NuGet but when I try to use it using:
using Facebook;
visual studio says that it cannot find the namespace name. I checked my references list and Facebook is on the project's reference list.
I tried to follow the instructions from this post on code project.
http://www.codeproject.com/Articles/20032/Creating-a-simple-Facebook-Application-using-WPF
All the examples that I found so far online do not suggest for a problem of that nature.
any suggestions?
Sometimes some NuGet issues require to re-open the project with the referenced assembly to load it. This problem is not Facebook-specific.

VS2010 Silverlight templates not compiling: "WebContextBase is not defined". What's going on? How do I get this working?

I'm beginning my first explorations into Silverlight RIAs and EF4, but I can't get a project to run right off the templates that ship with VS2010 SP1.
Bear in mind here that what I've done is to install a brand new Windows 7 VM, and then I immediately installed LightSwitch Beta 2. Following that, I added VS2010 Premium, and applied Service Pack 1 to that.
The client portion of the Template app is kicking off three warnings and two errors; the details are posted below. It's looking for a WebContextBase class that it can't find, in code that it generated into Web.g.vb (and Web.g.cs) files. So far this project is entirely generated off the solution template; I haven't added a single line of code to what VS2010 generated.
I've since gotten EF4 to work fine in WinForms projects and Light Switch projects.
What's going on here, and how do I fix it?
------ Build started: Project: EF4Test, Configuration: Debug Any CPU
------ C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(21)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(22)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices.Client'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(23)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices.Client.ApplicationServices'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(34)
: error BC30002: Type 'WebContextBase'
is not defined.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(65)
: error BC30451: 'WebContextBase' is
not declared. It may be inaccessible
due to its protection level.
Have a look at LightSwitch Beta 2 Readme
There are few know issues with the LightSwitch. From the steps you have described to setup your system I would guess that the problem could be because
"2.1.1 Visual Studio 2010 users or
Visual Studio 2010 SP1 Beta1 users
must install Visual Studio 2010 SP1
before installing Visual Studio
LightSwitch Beta2"
You should try uninstalling LightSwitch Beta2 and then reinstall, and let us know if you get the same error.
Hope this helps.
Include this reference..
System.ServiceModel.DomainServices.Client.ApplicationServices

Resources