2010-11-02 94 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

相關問題