问题
In reference to this article on MSDN. The assembly, microsoft.xna.framework.dll
, has been added to the references and I'm using the namespace Microsoft.Xna.Framework.Audio
, however I receive an immediate error on the first step, shown below:
Microphone [error 1] mic = Microphone.Default [error 2];
Error 1: The type or namespace name 'Microphone' could not be found (are you missing a using directive or an assembly reference?)
Error 2: The name 'Microphone' does not exist in the current context
According to the MSDN article, I've added the necessary references (or if other references are necessary, they aren't listed), so I'm unsure why I'm getting the first error. I would assume the second error occurs because of the first error.
回答1:
Since you're using Windows 8, Microphone
class is not allowed on it, so you need to change your code, using MediaCapture
class instead.
This page could be useful to you.
回答2:
You are trying to subscribe to an event by specifying an event handler that does not exist. This event handler, in the form of a method generally (though you can do this with anonymous delegated and so on) must be present, and match the signature defined by the event.
回答3:
In addition to adding the reference to the assembly, you need to declare the namespace by adding a using
statement at the top of your file, or explicitly declare the namespace at every usage.
For example:
using Microsoft.Xna.Framework.Audio;
OR
Microsoft.Xna.Framework.Audio.Microphone mic = Microsoft.Xna.Framework.Audio.Microphone.Default;
来源:https://stackoverflow.com/questions/18870199/microphone-does-not-exist-in-current-context