Microphone does not exist in current context

ぐ巨炮叔叔 提交于 2020-01-15 08:14:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!