Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NETFX2_0

Hi,

 

I see this variable "NETFX2_0" used in some of the example projects iwth MS2005? 

What is it?

 

Just wondering!

 

Curt

0 Kudos
Message 1 of 8
(4,810 Views)

Hi Curt,

 

What were a couple of the examples you fould the variable in?

0 Kudos
Message 2 of 8
(4,797 Views)

Hi Corbin,

 

Project 'PlotWaveforms.2005' for example.

 

Here's a snippet of code

 

#If NETFX2_0 Then

            Private Function GenerateAnalogWaveform() As AnalogWaveform(Of Double)

#Else

            Private Function GenerateAnalogWaveform() As AnalogWaveform

#End If

 

 Dim freq As Integer = 2

Dim amplitude As Integer = 30

Dim data() As Double = New Double((SampleCount) - 1) {}

Dim i As Integer = 0

For i = 0 To (data.Length - 1)

         data(i) = (amplitude * Math.Sin((2 * i * Math.PI * freq) / SampleCount))

Next i

 

#If NETFX2_0 Then

         Dim waveform As AnalogWaveform(Of Double) = AnalogWaveform(Of Double).FromArray1D(data)

#Else

         Dim waveform As AnalogWaveform = AnalogWaveform.FromArray1D(data)

#End If

 

I poked around in the project properties page and found the variable listed in Compile\Advanced Compile Options

as a trace variable.

 

Curt

0 Kudos
Message 3 of 8
(4,792 Views)
You should notice that NETFX2_0 is listed as a conditional compilation symbol. This is actually a way we can make our example code modular for different versions of the .NET Framework. We can simply add any code, such as declarations, that may differ between versions of the .NET Framework and then use the compilation symbol to determine which section of code to use.
Hopefully this helps out! Let me know if you have any questions.
Message Edited by CorbinH on 01-27-2009 10:24 AM
Message Edited by CorbinH on 01-27-2009 10:27 AM
0 Kudos
Message 4 of 8
(4,790 Views)

Something else I forgot to add is that using a conditional compilation symbol is how we modularize our examples to take advantage of generics and other features in the .NET 2.0 framework that are not supported in the 1.1 version.

0 Kudos
Message 5 of 8
(4,779 Views)

Hi,

 

I am also trying to understand the conditional compilation code.  I am looking at the Visual Basic example "AcqVoltageSamples_ExtClk," and I see the same block of conditional compilation code.

 

This is probably more of a Visual Basic question, but how does the compiler "know" which branch to take when it comes to the conditional compilation block?  I see that the constants NETFX2_0 and NETFX3_5 are defined in the advanced compiler settings for the project (under project properties). If I understand correctly what I've read in Microsoft's documentation, these are Boolean constants, and to define as true they are set to be set to -1.  So, does that mean if I am targeting the .NET 3.5 framework, I would put -1 next to the NETFX3_5 (i.e. NETFX3_5 = -1) in the custom constants text box in the advanced compiler options menu?

 

Thanks for your help.

 

Jason

0 Kudos
Message 6 of 8
(3,611 Views)

echemist,

 

These constants just need to be defined to be true. So if they exist in the Custom constants field, then they are defined and thus that code will be included during compilation. You do not need to set them to any value. You can see that if you remove one from the Custom constatns list, the code in those blocks will be grayed out. You can also look at our examples for other versions of .NET and see that the list will only include the current version and those prior. So the .NET 2.0 example only defines NETFX2_0.

National Instruments
0 Kudos
Message 7 of 8
(3,601 Views)

Thanks for your help.  I wasn't able to get the code to grey out by removing the constants, but that is probably a problem with my Visual Basic IDE (Visual Basic 2008 express).  I posted to the MSDN forum to find out if maybe there is an incorrect setting or something else that I need to change in the Visual Basic IDE.

0 Kudos
Message 8 of 8
(3,589 Views)