Visusal Studio 2010 Express 中忽略了 C# 预处理器指令?
我从 codeProject。
#if
预处理器指令似乎没有像我预期的那样工作。
我还没有在MyProject>>中定义DSHOWNET属性>>构建选项卡>>条件编译符号(对话框为空)
在下面的代码中,项目构建时出现错误无法找到DShowNET。由于 DSHOWNET 从未被定义,我很惊讶“using DShowNET”竟然被处理了。
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
#if 预处理器指令在 Visual Studio Express 版本中工作吗? DSHOWNET 是否需要显式“未定义”?或者我错过了一些其他基本概念?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我下载了示例采集器项目并将其放在我的系统上。 (我使用的是 Enterprise VS。)我打开了
CaptureTest-2005
解决方案,将其转换为 VS2010 解决方案,然后加载它。加载CaptureTest-2005
解决方案后,我仍然看到与您所看到的问题相同的文件。因此,我发现,虽然
CaptureTest-2005
项目没有在“构建”页面上定义DSHOWNET
,但DirectX.Capture-2005
> 项目做到了。因此,对于DirectX.Capture-2005
中的所有文件,DSHOWNET
指令的计算结果为 true,因此#if DSHOWNET
中的项目正在处理指令。我不确定该解决方案是否只需要您构建并使用 CodeProject 下载的
DSHOWNET
部分(例如,我不确定是否需要DirectX.Capture
)但我想,由于 DirectX.Capture 项目已定义它,因此您将必须构建并使用该程序集来运行该项目。 (可能有一种解决方法,我还没有深入研究它。我建议检查项目页面,看看是否有关于什么取决于什么的信息。)希望这会有所帮助!
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 theCaptureTest-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 haveDSHOWNET
defined on the Build page, theDirectX.Capture-2005
project did. So, for all the files inDirectX.Capture-2005
, theDSHOWNET
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 whetherDirectX.Capture
is required) but I imagine, since theDirectX.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!