“元帅”这个名字当前上下文中不存在

发布于 2024-09-08 12:53:07 字数 1505 浏览 7 评论 0原文

我从位图混合器示例(DirectShow.NET)中获取了下面的代码,并尝试重新实现它。原始样本工作正常。在我的版本中,当我尝试编译时出现错误。

private void AddHandlers()
    {
        // Add handlers for VMR purpose
        this.Paint += new PaintEventHandler(Form1_Paint); // for WM_PAINT
        this.Resize += new EventHandler(Form1_ResizeMove); // for WM_SIZE
        this.Move += new EventHandler(Form1_ResizeMove); // for WM_MOVE
        SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged); // for WM_DISPLAYCHANGE
        handlersAdded = true;
    }

    private void RemoveHandlers()
    {
        // remove handlers when they are no more needed
        handlersAdded = false;
        this.Paint -= new PaintEventHandler(Form1_Paint);
        this.Resize -= new EventHandler(Form1_ResizeMove);
        this.Move -= new EventHandler(Form1_ResizeMove);
        SystemEvents.DisplaySettingsChanged -= new EventHandler(SystemEvents_DisplaySettingsChanged);
    }


错误


错误 1 ​​当前上下文 Form1.cs 中不存在名称“Marshal”
错误 2 当前上下文 Form1.cs 中不存在名称“Marshal”
错误 3 当前上下文 Form1.cs 中不存在名称“Form1_ResizeMove”
错误 4 当前上下文 Form1.cs 中不存在名称“Form1_Paint”
错误 5 当前上下文 Form1.cs 中不存在名称“Form1_ResizeMove”
错误 6 当前上下文 Form1.cs 中不存在名称“Form1_ResizeMove”
错误 7 当前上下文 Form1.cs 中不存在名称“SystemEvents_DisplaySettingsChanged”
错误 10 当前上下文 Form1.cs 中不存在名称“Form1_ResizeMove”
错误 11 当前上下文 Form1.cs 中不存在名称“SystemEvents_DisplaySettingsChanged”


如有任何帮助,我们将不胜感激。

谢谢。

I got the code below from the bitmapmixer sample (DirectShow.NET) and i tried to reimplement it. The original sample works fine. In my version when I try to compile i get errors.

private void AddHandlers()
    {
        // Add handlers for VMR purpose
        this.Paint += new PaintEventHandler(Form1_Paint); // for WM_PAINT
        this.Resize += new EventHandler(Form1_ResizeMove); // for WM_SIZE
        this.Move += new EventHandler(Form1_ResizeMove); // for WM_MOVE
        SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged); // for WM_DISPLAYCHANGE
        handlersAdded = true;
    }

    private void RemoveHandlers()
    {
        // remove handlers when they are no more needed
        handlersAdded = false;
        this.Paint -= new PaintEventHandler(Form1_Paint);
        this.Resize -= new EventHandler(Form1_ResizeMove);
        this.Move -= new EventHandler(Form1_ResizeMove);
        SystemEvents.DisplaySettingsChanged -= new EventHandler(SystemEvents_DisplaySettingsChanged);
    }


ERRORs


Error 1 The name 'Marshal' does not exist in the current context Form1.cs
Error 2 The name 'Marshal' does not exist in the current context Form1.cs
Error 3 The name 'Form1_ResizeMove' does not exist in the current context Form1.cs
Error 4 The name 'Form1_Paint' does not exist in the current context Form1.cs
Error 5 The name 'Form1_ResizeMove' does not exist in the current context Form1.cs
Error 6 The name 'Form1_ResizeMove' does not exist in the current context Form1.cs
Error 7 The name 'SystemEvents_DisplaySettingsChanged' does not exist in the current context Form1.cs
Error 10 The name 'Form1_ResizeMove' does not exist in the current context Form1.cs
Error 11 The name 'SystemEvents_DisplaySettingsChanged' does not exist in the current context Form1.cs


Any help is appreciated.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

涫野音 2024-09-15 12:53:07

元帅类位于 System.Runtime.InteropServices 命名空间中。您有合适的 using 指令吗?

using System.Runtime.InteropServices;

至于其他错误 - 你的类中有这些方法吗?如果没有,请删除尝试为其订阅事件处理程序的行...

The Marshal class is in the System.Runtime.InteropServices namespace. Do you have an appropriate using directive?

using System.Runtime.InteropServices;

As for the other errors - do you have those methods in your class? If not, remove the lines which are trying to subscribe event handlers for them...

累赘 2024-09-15 12:53:07

public static class Marshal 是 System.Runtime.InteropServices 的成员,

您只需添加:

using System.Runtime.InteropServices;
在那个 .cs 文件中

public static class Marshal is a Member of System.Runtime.InteropServices

you just have to add:

using System.Runtime.InteropServices;
in that .cs file

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