cdub
cdub

Reputation: 25741

Compilation issue in C# .NET

I have the following code (inherited from a contractor):

public partial class StoredProcedures  
{  
    #if NO_THREAD      
        readonly static String version = "XXXX, Version 1.02, Apr/29/2010";
    #else 
        readonly static String version = "XXXX, Version 0.93, Dec/21/2006";
    #endif

I can't seem to find NO_THREAD anywhere else. This is code that compiles and installs as a SQL assembly. Is it something special or am I missing something simple?

Upvotes: 0

Views: 133

Answers (6)

Sasha
Sasha

Reputation: 856

Try to check Project Properties->Build->General->Conditional compilation symbols for all Build configurations which you have for the project, It may be there.

Upvotes: 4

JamieSee
JamieSee

Reputation: 13030

This is a conditional compilation symbol. In Visual Studio 2010, these appear on the Build page of your Project Properties in the Conditional compilation symbols text box. Probably one of your Configuration Manager configurations either contains this symbol or has at some point in the past. Presumably, there is another #if somewhere that disables a block of code that uses multiple threads if the NO_THREAD symbol is present.

Upvotes: 0

Jon Hanna
Jon Hanna

Reputation: 113352

NO_THREAD is a symbol for conditional compilation.

It can come from, #define NO_THREAD, from the project file, or from the nant file (or whatever method you use for building).

If it's defined, the first line of code is counted as part of the C# code. If it isn't, then the second is.

If that's the sole occurence, I'd say it was a hangover from something removed, but if you're uesd to using visual studio to build, then make sure there isn't a build file for nant in case the previous developer used that instead.

Upvotes: 0

Parv Sharma
Parv Sharma

Reputation: 12705

you should probably have a look at the c# pre-processor directives

No_Thread here is a symbol which can be defined by using #define No_Thread and when #define No_Thread is present then #if NO_THREAD will result in true and at compile time readonly static String version = "XXXX, Version 1.02, Apr/29/2010"; this statement will be compiled otherwise the next statement will be compiled.

this is generally used to differentiate between debug and release versions. have you noticed there are 2 versions in VS when you create a new project. if you write something like this somewhere in you code

 #if DEBUG
 Console.WriteLine("DEBUG VERSION");
 #endif

then the string "DEBUG VERSION" would only be printed on the console when the project is in debug mode because the VS inserts a symbol DEBUG if you manually do it using the #define pre-processor then too this line would be compiled

Upvotes: 0

Icarus
Icarus

Reputation: 63972

If you can't find a

define #NO_THREAD

Anywhere in the code, then it's probably because the contractor was defining the symbol by passing the /define compiler option.

See here for more details (typing from a cell, sorry for the format):

http://msdn.microsoft.com/en-us/library/0feaad6z.aspx

Upvotes: 1

brendan
brendan

Reputation: 29996

Look for a #define statement. See the docs for #if preprocessor conditionals : http://msdn.microsoft.com/en-us/library/4y6tbswk.aspx

Upvotes: 1

Related Questions