I have recently found out that (merely) installing Visual Studio 2012 on my machine, causes Visual Studio 2010 to use the newer C# compiler. This happens even when setting the language version to 4 (http://ericlippert.com/2013/04/04/what-does-the-langversion-switch-do/).
I wanted to know if it were possible to force Visual Studio to use the old compiler anyway. I think it's not possible because it seems that the compiler is installed in the framework folder which is the same for .NET 4 and .NET 4.5, but I was wondering if someone managed to do it anyway somehow.
You can use the command line compiler see here, and run your code on the old compiler in post build actions
As I said in my original question and as some commented, it indeed seems this would be impossible. The new compiler is installed in the same place as the old compiler. One would need to have a clean build environment with the exact compiler needed.
Related
Before any question, I did a lot of research on Google and S.O. , and I found only old and obsolete threads without any help for my problem.
so...
1. First question:
I wonder if it's possible to target the installed Mono framework directly from Visual Studio 2019.
I know that at the time of writing, Mono 6.4.0.198 is released and it supports almost all features of .NET 4.7 (and C# 7.0), so I created a simple project targeting FW4.7.2 and it works fine so far.
I just wanted to know if I can create a project entirely on Mono Framework with no other reference than Mono assemblies.
I did a lot of research and the only thing I found is this: https://erictummers.com/2012/01/25/target-mono-from-visual-studio/
but i'd rather not mess with the registry and assemblies files.
2. Second question:
I would like to build and debug my Mono code directly on the target machine (Raspberry Pi). It's possible to do so in Visual Studio 2019?
I managed to compile a C++ program directly on the RasPi, so i thought it might be possible to do the same for Mono/C#.
Any help would be very appreciated!
For some reason, even so much as typing this into a C# file in Visual Studio is enough to cause it to instantly crash. Why?
unsafe struct node {
node*[] child;
}
It seems to occur when the IDE would start coloring keywords and the like.
Trying it in TIO spits out csc.exe exited with code 1 which isn't very helpful.
While array declarations in C# are different than in C/C++, the above seems like it should be perfectly valid. Why isn't it, and why does it crash Visual Studio?
My Visual Studio version is 14.0.23107.
This is a known bug in Roslyn. This bug will affect any version of Visual Studio that uses Roslyn.
If I am interpreting VersionOf.net correctly, the first version of Visual Studio with Roslyn built-in is 2015. Before then, I think it was available only as an extension. So, Visual Studio 2013 and prior should be unaffected.
It's due to be fixed in the milestone 16 release. At this time, that release is not scheduled.
Because this is a bug in Roslyn, you can "get around" it by editing and compiling the code containing the unsafe struct in an older version of Visual Studio, one that predates Roslyn. Visual Studio 2012 should work. You can then use the resultant .DLL in your current software.
An unverified fix is available if you build Roslyn yourself from this branch. The fix was made in this commit.
I am trying to start using the c#.net api for ibm cplex v12.6. However, I have trouble in the installation:
IBM page is telling me i need to set the compiler and linker:
https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.6.3/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/tutorials/Csharp/prerequisites.html
but what exactly do i need to do?
I am also confused by visual studio versions: is the community 2013 ok?
Thank you
Just run the CPLEX installer and take the default options. It will install everything you need to use CPLEX with Visual Studio (and a lot more as well), and should be compatible with any recent version of VS. Only real decision is whether to install the 32 or 64 bit version (or both). It'll put a mountain of stuff in somewhere like 'C:\Program files\IBM' but you can ignore most of it when working with C# and .Net
When I am working with Visual Studio and C#, I pretty much only ever use stuff in one folder such as:
C:\Program Files\IBM\ILOG\CPLEX_Studio1271\cplex\bin\x64_win64
Obviously you need to have a compiler and linker to do stuff with C#, and Visual Studio is the obvious choice. I have used many combinations of versions over the years (currently using 64-bit CPLEX 12.4, 12.5.1, 12.6.3 and 12.7.1 on various projects, with VS2008, VS2010 and VS2015, both pro and community editions) so I can't see why you would have a problem.
I've a bit of confusion about roslyn.
What I have done:
I've installed vs 2015 community edition and download in extensibilty > download compiler platform sdk.
So I created a simple console application: hello world example.
Well now I'm expect to choise the c# compiler between the vs2015 default one and roslyn..., but I've not found such option.
So my first question is: how to select version of c# compiler?
Second I've downloaded master-roslyn and I build, then I found csc.exe, well the odd things is that if I lauch the exe
I get c# compiler version 42.42.42.42. ???? Right?
Then I've follow some tutorials, but all purpose me:
to load a source from text file or string vars and analyze or change syntax tree, then compile to var.
Well at this point I'm confused... So:
What is roslyn exactly? A meta compiler? This mean that I can change my code at runtime just like Reflection?
Second: how can compile with vs2015 with default csc or choose roslyn?
third: If I build a custom version of roslyn How can I compile my source using Vs2015 ?
Which know if csc.exe is roslyn? No help or command line print the codename.
Thanks
So it looks like you've got a few questions:
What is Roslyn?
Roslyn is the new default compiler inside of Visual Studio 2015. If you're building and running applications within Visual Studio 2015, they're being compiled with the Roslyn compiler. You'll get to take advantage of all the new C# 6 features that are available only within the new compiler.
If you're using VS2015, Roslyn has replaced the old compiler entirely and as far as I know you can't use the old compiler within VS 2015.
Roslyn is also a platform that allows you to build programs that can modify, interpret and understand other programs. It's not really meant to let you write code that modifies itself (although that's probably possible to a degree).
The common use cases for Roslyn are:
Building Code Analyzers that provide errors and warnings within Visual Studio.
Building extensions for Visual Studio that understand source code.
Building other tools that understand or run source code. Example: ScriptCS - Scripting with C# code.
In order to use Roslyn for these purposes, you pull down the Microsoft.CodeAnalysis packages from NuGet. You can use these packages to parse code, analyze syntax trees, analyze symbols or compile code and emit IL.
If you're interested in learning more about Roslyn, I've started a series called Learn Roslyn Now that you might be interested in.
Can I replace the compiler?
Yes you can, but I'm not convinced this is a great idea outside of testing changes you want to contribute back to Roslyn. You can pull down Roslyn from GitHub and follow these instructions to build and run Roslyn from within Visual Studio.
If you follow those instructions, you'll be able to run the Roslyn project with F5. It will start a new instance of Visual Studio that's using your customized compiler. This is how people outside of Microsoft will contribute features to the compiler from now on. (Previously you couldn't deploy your custom compiler to Visual Studio but they fixed that in Visual Studio Update 1).
Roslyn is two things:
An API that lets you see "compiler things" like syntax trees and symbols.
A new csc.exe that is implemented atop #1.
If you want to make changes to the compiler and use that to build, take a look at these instructions if you haven't already. There's a few different ways you can make your own version of csc.exe and then use that to build something. But there's no "choice" dialog like you're looking for.
Roslyn is the default compiler of Visual Studio 2015. So, if you install VS2015 you´re already using Roslyn.
Roslyn is a codename for .NET Compiler Platform, and it provides open-source C# and Visual Basic compilers. The project is available on github.
This is a follow-up to: Projection using async delegate/lambda
Apparently, the Async CTP has a bug that I've hit into, and I need to use the VS11 compiler. At the command-line, running msbuild even against a project written in VS2010 still compiles with the VS11 compiler because VS11/.NET 4.5 installs in-place in the .NET 4.0 directory.
However, inside Visual Studio 2010, an in-process compiler is used which seems to not have been upgraded to the new VS11 compiler.
Can I (through some hackery / DLL manipulation) change the compiler that Visual Studio 2010 uses? This would just be a hack/workaround until VS11 supports Windows Azure, so that I can upgrade to the beta/release candidate/RTM.
You may run into some success using the little-known property UseHostCompilerIfAvailable. That should cause build within the IDE to use the compiler in the framework directory.
However IDE features such as intellisense will always use the in-proc compiler. If the bug you're hitting is only on the final transformations of async methods though, you may find that the in-proc compiler is good enough for intellisense, and that UseHostCompilerIfAvailable is good enough to allow you to build from VS.
You set it by manually editing your csproj file to include
<UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
in the top property group.
Also - VS11 supports "roundtripping"! In most scenarios you can open your VS10 project using VS11 without forcing an upgrade. Thus if you have a team need to keep your project in the V10 format for the time being, you can at least independently use VS11. However, this is harder if there are addins that you need that have yet to be released for VS11.
Hope this helps! :)