Visusal Studio 2010 Express 中忽略了 C# 预处理器指令?

发布于 2024-11-29 17:07:40 字数 796 浏览 0 评论 0原文

我从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

原谅过去的我 2024-12-06 17:07:40

我下载了示例采集器项目并将其放在我的系统上。 (我使用的是 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 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文