Questions tagged [csc]

Csc.exe is the command-line compiler for C# from Microsoft.

Csc.exe is the command-line compiler for C# from Microsoft.

301 questions
17
votes
5 answers

Why is the .ctor() created when I compile C# code into IL?

With this simple C# code, I run csc hello.cs; ildasm /out=hello.txt hello.exe. class Hello { public static void Main() { System.Console.WriteLine("hi"); } } This is the IL code from ildasm. .class private auto ansi…
prosseek
  • 182,215
  • 215
  • 566
  • 871
15
votes
1 answer

How can I target a specific language version using CodeDOM?

Using the C# code provider and the ICodeCompiler.CompileAssemblyFromSource method, I am attempting to compile a code file in order to produce an executable assembly. The code that I would like to compile makes use of features such as optional…
Caster Troy
  • 2,796
  • 2
  • 25
  • 45
14
votes
4 answers

The specified task executable location ......csc.exe is invalid error

I have a project on TFS that is working on everyone else's machine, except mine. When building I get the error that can be seen in the image. "The specified task executable location csc.exe is invalid." currently trying to repair VS 2017 now.
Ha66y-Day
  • 197
  • 1
  • 2
  • 12
12
votes
5 answers

Visual Studio gone bonkers: 'The directory name is invalid' error when trying to compile

For some very odd reason, my Visual Studio 2008, when trying to compile a C# project, tries to write the output of the executable to a directory with the same name as an executable, at least it seems that that's what the error message implies. After…
Abel
  • 56,041
  • 24
  • 146
  • 247
11
votes
3 answers

'Arrays as attribute arguments is not CLS-compliant' warning, but no type information given

When compiling my solution, I get several warnings of the following: warning CS3016: Arrays as attribute arguments is not CLS-compliant No other information on what type is not compliant is given. In my projects I have some attributes that take…
thecoop
  • 45,220
  • 19
  • 132
  • 189
11
votes
3 answers

csc.exe reference external .dll file

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…
RanRag
  • 48,359
  • 38
  • 114
  • 167
10
votes
2 answers

Including FSharp.Core in a C# project: resolving type collisions

I'm using some F# types (Matrix et al) from C# and so I need to reference the FSharp.Core assembly in my C# project. So far, so good. However, there are apparently some types defined in mscorlib.dll (v4) which are "duplicated" in FSharp.Core (v2),…
codekaizen
  • 26,990
  • 7
  • 84
  • 140
10
votes
4 answers

Why doesn't this recursion produce a StackOverFlowException?

What is wrong with this code: using System; namespace app1 { static class Program { static int x = 0; static void Main() { fn1(); } static void fn1() { …
sharp12345
  • 4,420
  • 3
  • 22
  • 38
10
votes
10 answers

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

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…
Greg Froning
  • 213
  • 1
  • 4
  • 16
9
votes
2 answers

Compile/Run single C# file on macOS

I'm able to develop .NET Core based C# apps through VS for Mac, and now I've created a "compiler" which generates C# for a language I created. I would like to at least run the output (a single file called Program.cs) and hopefully compile it to an…
deeBo
  • 836
  • 11
  • 24
9
votes
1 answer

What does publicsign do?

What does the -publicsign option to the C# compiler do? I have read the documentation but still don't understand https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/publicsign-compiler-option This option causes the…
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
9
votes
2 answers

How do I set csc langversion when building in VSTS?

I have a simple test console app. The only code it has is public class Class1 { private protected int _value = 0b_1001_0110; } which is just to test whether these C# 7.2 features will build or not. In Visual Studio 2017 15.5.2 they build fine…
Phil
  • 42,255
  • 9
  • 100
  • 100
9
votes
1 answer

C# compiler (csc.exe) memory overflow compiling nested types and Linq

I found one unpleasant behavior developing with Visual Studio. It was hanging my machine while compiling C#. I have reduced behavior to the next minimal source code using System.Collections.Generic; using System.Linq; namespace…
josejuan
  • 9,338
  • 24
  • 31
9
votes
5 answers

Is compiling Release and Debug going to generate different IL code + different machine code?

I heard compiling in Release mode generates optimized code than in Debug mode, which is fine. But is this optimization in the IL? is it in the machine code once the CLR runs it? is the metadata structure different from PE compiled in Release and…
RollRoll
  • 8,133
  • 20
  • 76
  • 135
9
votes
1 answer

Escape Catch-22 with extension attributes in .NET 2.0

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…
Lilith River
  • 16,204
  • 2
  • 44
  • 76
1
2
3
20 21