views:

76

answers:

2

Hi, what does the following code mean and what does it do ? Is it really required ?

 #if !USING_NET11
 using System.Runtime.InteropServices.ComTypes;
 #endif

In my project file I have implemented the web cam capture using the dshownet wrapper. The above code was there in the Form1.cs file.

Many Thanks

+1  A: 

The System.Runtime.InteropServices.ComType was introduced in .NET Framework version 2.0. The code appears to be attempting to be compatible with the 1.1 version of the framework by only declaring the using statement on that namespace if the version being compiled against isn't 1.1.

If you do a Google search on USING_NET11, you'll find it points to a lot of managed DirectX code.

Adam Robinson
+1  A: 

It means that:

using System.Runtime.InteropServices.ComTypes;

will only be compiled into the assembly if the symbol USING_NET11 is false.

Since System.Runtime.InteropServices.ComTypes was added in .NET 2.0, this directive means that the code will still compile against .NET 1.1 since the new reference won't be compiled in.

Justin Niessner