2010-11-02 59 views
0

我已经将MIDI.dll添加到程序集属性中,我是C#的新手,并且遵循MIDI.dot.net中的一个示例,并在device.Spec上得到了此错误,Midi.InputDevice的含义不包含'spec'的定义,没有扩展方法'spec'接受Midi.InputDevice类型的第一个参数无法找到(你是否缺少使用指令...)?“foo不包含'bar'的定义...”是什么意思?

我的using MIDI位于顶部,我使用MonoDevelop IDE。

public override void Run() 

     { 

      // Print a table of the input device names, or "No input devices" if there are none. 

      if (InputDevice.InstalledDevices.Count == 0) 

      { 

       Console.WriteLine("No input devices."); 

      } 

      else 

      { 

       Console.WriteLine("Input Devices:"); 

       foreach (InputDevice device in InputDevice.InstalledDevices) 

       { 

        Console.WriteLine(" {0}", device.Spec); 

       } 

      } 

      Console.WriteLine(); 



      // Print a table of the output device names, or "No output devices" if there are none. 

      if (OutputDevice.InstalledDevices.Count == 0) 

      { 

       Console.WriteLine("No output devices."); 

      } 

      else 

      { 
+0

MIDI dll从哪里来?错误基本上意味着您的输入设备没有属性名称“Spec”。你确定这样的财产存在吗? – 2010-11-02 12:34:49

+0

重建midi.dll,您使用的版本显示已过时。源代码位于:http://code.google.com/p/midi-dot-net/source/browse/trunk/Midi/ – 2010-11-02 14:30:29

回答

2

你写代码的方式,我希望Spec是InputDevice的一个属性。

根据您收到的错误信息,情况并非如此。在InputDevice类型中没有名为Spec的成员。

看看这里的文档:InputDevice Class它绝对看起来应该是一个有效的属性。在你的例子中,你有Spec大写,但在你提供的错误消息中,它是小写。我的猜测是,你的真实代码是小写字母。

C#区分大小写,这可能是您为什么会收到错误。

+0

代码实际上是此示例:http://code.google.com/p /midi-dot-net/source/browse/trunk/ConsoleDemo/Example01.cs – 2010-11-02 12:56:07

+0

0xA3 - 这是粘贴的例子,是的。尽管看看OP的错误。它清楚地说'整个'规范'导致我相信他们的代码中存在一个简单的案例问题(这意味着它可能不是复制/粘贴)。 – 2010-11-02 12:57:44

0

用'Name'替换'Spec',它会完美的工作!

+0

这些似乎是两个不同的东西。 – 2012-10-19 21:28:40

相关问题