NAudio in Windows Azure /Windows Server 2008 R2

折月煮酒 提交于 2019-12-01 14:37:55
Mark Heath

See my answer to this question. Also, you need to be sure you are running a 32 bit process, as most ACMs are 32 bit.

I battled this myself, and these are the steps to follow:

Manually:

  1. Via Server Manager you can add the Windows Feature "Desktop experience"
  2. Reboot the server as requested (you must for it to take effect)
  3. You can now use the regular Mp3 audio codec NAudio uses (you don't need the Dmo one)

Automatically (Azure deployments):

Add these commands to a Startup.cmd startup task in Azure for your role:

echo Begin Install Desktop Experience Feature (for sound codec) >> startup.log
ServerManagerCMD.exe -install Desktop-Experience -restart -resultPath     desktopexperience_results.xml
REM This return code indicates the feature is already installed. Reset the errorlevel to zero using the verify command.
IF %ERRORLEVEL% EQU 1003 (
    echo Windows feature is already installed >> startup.log
    VERIFY > NUL
)
echo End Install Desktop Experience Feature >> startup.log

Note that it is important this script returns a result code (%ERRORLEVEL%) of zero (which the above will do, bar any actual problems).

The ServerManagerCMD will return a non-zero error code when it does not need to install the feature (perhaps because it was already installed from a previous Startup.cmd run), so we explicitly need to check for that code (1003) and silence it using VERIFY > NUL.

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