I have a section of code downloaded from codeProject.
The #if
preprocessor directive doesn't appear to work like I would have expected it to work.
I have not defined DSHOWNET in MyProject >> Properties >> Build Tab >> Conditional compilation symbols (the dialog box is empty)
In the code below, an error DShowNET could not be found is shown when the project is built. Since DSHOWNET was never defined, I'm surprised that the 'using DShowNET' is even processed.
using System;
using System.Collections;
using System.Runtime.InteropServices;
#if DSHOWNET
using DShowNET;
using DShowNET.Device;
#else
#if VS2003
#else
using System.Runtime.InteropServices.ComTypes;
#endif
using DirectShowLib;
#endif
Does the #if preprocessor directive work in the Visual Studio Express version? Does DSHOWNET need to be explicitly 'undefined'? Or am I missing some other basic concept?
I downloaded the sample grabber project and put it on my system. (I am using the Enterprise VS.) I opened the CaptureTest-2005
solution, converted it to a VS2010 solution, and loaded it. Upon loading the CaptureTest-2005
solution, I still saw files that had the same issue as you are seeing.
So, what I found was that, although the CaptureTest-2005
project did not have DSHOWNET
defined on the Build page, the DirectX.Capture-2005
project did. So, for all the files in DirectX.Capture-2005
, the DSHOWNET
directive evaluated to true, and thus the items inside the #if DSHOWNET
directives were being processed.
I am not sure whether the solution just requires that you build and use the DSHOWNET
part of the CodeProject download, (e.g. I'm not sure whether DirectX.Capture
is required) but I imagine, since the DirectX.Capture
project has it defined, that you will have to build and use that assembly to run the project. (There may be a way around it, I have not gone that far into it. I would recommend checking the project page to see if there's information about what depends on what.)
Hope this helps!