Search code examples
runtimesysteminteropservicescomtypes

What does #if !USING_NET11 using System.Runtime.InteropServices.ComTypes; #endif mean?


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.


Solution

  • 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.