“元帅”这个名字当前上下文中不存在
我从位图混合器示例(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
元帅
类位于 System.Runtime.InteropServices 命名空间中。您有合适的using
指令吗?至于其他错误 - 你的类中有这些方法吗?如果没有,请删除尝试为其订阅事件处理程序的行...
The
Marshal
class is in theSystem.Runtime.InteropServices
namespace. Do you have an appropriateusing
directive?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...
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