csc

Difference in CSC and Roslyn compiler's static lambda expression evaluation?

99封情书 提交于 2019-11-28 13:40:40
Consider the following example code. class Program { static void Main( string[] args ) { DoSomethingWithAction( i => { Console.WriteLine( "Value: {0}", i ); } ); Console.ReadLine(); } private static void DoSomethingWithAction( Action<int> something ) { Console.WriteLine( something.Target == null ? "Method is static." : "Method is not static." ); something( 5 ); } } If I compile and run this code under Debug using the Visual Studio 2010 (under CSC compiler) it will print out the following result: Method is not static. Value: 5 If I compile the same code in Visual Studio 2010, but this time

Escape Catch-22 with extension attributes in .NET 2.0

怎甘沉沦 提交于 2019-11-28 11:11:55
How can a single .NET assembly, targeting 2.0, 3.0, 3.5, 4.0, and 4.5 concurrently, support extension methods for both C# and VB.NET consumers? The standard suggestion is to add this: namespace System.Runtime.CompilerServices { public sealed class ExtensionAttribute : Attribute { } } This the approach suggested by more than one Microsoft employee and was even featured in MSDN magazine . It's widely hailed by many bloggers as having 'no ill effects'. Oh, except it will cause a compiler error from a VB.NET project targeting .NET 3.5 or higher. The authors of Microsoft.Core.Scripting.dll figured

Visual Studio 2012 csc.exe Error. Executable not valid for OS

China☆狼群 提交于 2019-11-28 07:15:32
问题 I am getting the following error when trying to compile and test any type of project in Visual Studio 2012 Professional. Error 1 The specified task executable "Csc.exe" could not be run. The specified executable is not a valid application for this OS platform. After testing multiple suggestions online nothing has fixed the problem. Anyone know what is causing this? Is there a new version of Csc.exe I need to get a hold of? I know this is the compiler just not sure what I need to do to fix the

How to use references when compiling c# code via command line

社会主义新天地 提交于 2019-11-27 22:33:13
问题 Could anyone help me compile via command line some c# files? I have 4 files to compile, Main, Form1 (which uses 2.cs file) and another class used in the project. I would like to compile this project in command line so I could add the /t:library switch (like in this tutorial: http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx). However after using "csc /t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs" I get missing assembly reference

How to Compile C# with Specific Language Version

柔情痞子 提交于 2019-11-27 17:26:57
问题 Let's say I want to demo to someone about the differences between foreach in C# 4.0 and 5.0. So I write up my code snippet: public static void Main() { string[] fruits = { "Apple", "Banana", "Cantelope" }; var actions = new List<Action>(); foreach (var fruit in fruits) { actions.Add(() => Console.WriteLine(fruit)); } foreach(var a in actions) { a(); } } But no matter how I compile it, it always works as it does in 5.0 * . I've tried setting the language version in the csproj file (Build ->

csc.exe reference external .dll file

大兔子大兔子 提交于 2019-11-27 09:17:21
I am trying to make a simple c# program using Growl C# API . I tried to compile my program in two different ways: 1) I kept my .dll file in the same directory as my .cs file. Than I ran csc /r:Growl.Connector.dll,Growl.CoreLibrary.dll /out:test.exe *.cs It compiled fine and also ran fine. 2) Now I have created a directory inside my current working directory named growl and kept all my .dll references there. Now when I try to compile it using the below command csc /r:"D:\Modified\Growl_NET_Connector_SDK\libraries\growl\Growl.Connector.dll","D: \Modified\Growl_NET_Connector_SDK\libraries\growl

Difference in CSC and Roslyn compiler's static lambda expression evaluation?

↘锁芯ラ 提交于 2019-11-27 07:47:06
问题 Consider the following example code. class Program { static void Main( string[] args ) { DoSomethingWithAction( i => { Console.WriteLine( "Value: {0}", i ); } ); Console.ReadLine(); } private static void DoSomethingWithAction( Action<int> something ) { Console.WriteLine( something.Target == null ? "Method is static." : "Method is not static." ); something( 5 ); } } If I compile and run this code under Debug using the Visual Studio 2010 (under CSC compiler) it will print out the following

How to get csc.exe path?

旧时模样 提交于 2019-11-27 04:20:30
Is there a way to get path for the latest .NET Framework's csc.exe? The file usually in: c:\Windows\Microsoft.NET\Framework\vX.X.XXX but the problem is there can be multiple versions installed + there are both 32 and 64 bit versions. Any solution to this? c:\Windows\Microsoft.NET\Framework\vX.X.XXX Should contain the latest 32 bit version of csc.exe c:\Windows\Microsoft.NET\Framework64\vX.X.XXX Should contain the lastest 64 bit version of csc.exe That's what it is for mine anyway. BTW: You can access both by using the Visual Studio Command Line from your visual studio tools folder in your

Is it possible to install a C# compiler without Visual Studio?

♀尐吖头ヾ 提交于 2019-11-27 03:10:24
I want to build projects from the command line. Is it possible to deploy a C# compiler without installing Visual Studio ? Sure, the framework includes a compiler, csc.exe. Look at this article for a quick how-to. The important parts: You can get the command-line compiler (csc.exe) from Microsoft site http://msdn2.microsoft.com/en-us/netframework/aa731542.aspx . Download the redistributable package of the .NET Framework, which includes the compiler and the .NET Framework with C# 2005 syntax support. The compiler is located in the following directory: %windir%\Microsoft.NET\Framework\ Also look

Is there a way to get the build command line used by Visual Studio?

跟風遠走 提交于 2019-11-27 01:52:24
问题 I want to do a build from the command line, but I'd like to get the exact command line syntax from Visual Studio (2012), so that I don't have to manually figure out all of the flags, imports, and other parameters. Is there a way to get Visual Studio to display this information? 回答1: When you build a project or solution in Visual Studio, the entire command line used to run the compiler (csc.exe, including switches and parameters) is displayed in the Output window. If you don't see it there,