2013-11-28 37 views
0

當我運行包含NAudio庫的程序時,出現以下「由於其保護級別而無法訪問」錯誤。當我運行包含NAudio lib的程序時,出現以下錯誤(WaveInterop.mmioStringToFOURCC)無法訪問

public void ReadWaveHeader(Stream stream) 
{ 
    this.dataChunkPosition = -1; 
    this.waveFormat = null; 
    this.riffChunks = new List<RiffChunk>(); 
    this.dataChunkLength = 0; 

    BinaryReader br = new BinaryReader(stream); 
    ReadRiffHeader(br); 
    this.riffSize = br.ReadUInt32(); // Read the file size (minus 8 bytes) 

    if (br.ReadInt32() != WaveInterop.mmioStringToFOURCC("WAVE", 0)) 
    { 
     throw new FormatException("Not a WAVE file - no WAVE header"); 
    } 

    if (isRf64) 
    { 
     ReadDs64Chunk(br); 
    } 

    int dataChunkID = WaveInterop.mmioStringToFOURCC("data", 0); 
    int formatChunkId = WaveInterop.mmioStringToFOURCC("fmt ", 0); 

    // Sometimes a file has more data than is specified after the RIFF header 
    long stopPosition = Math.Min(riffSize + 8, stream.Length); 
+0

問題是waveintrop – Layan

+0

您運行的是什麼操作系統? –

+0

窗口8,問題是WaveInterop.mmioStringToFOURCC請我需要你的幫助,並覺得你 – Layan

回答

0

如果它是您正在創建的Windows應用商店應用程序,那麼您無法調用mmioStringToFOURCC。該NAudio 1.7 NuGet package包含一個預覽質量Windows應用商店的組件不調用mmioStringToFOURCC。但是,NAudio的Windows Store支持尚不完整。

如果你的意思是你有一個編譯錯誤,因爲你試圖從NAudio之外調用WaveInterop.mmioStringToFOURCC,那麼你不能因爲WaveInterop是NAudio內部的。並非所有的NAudio內部都是外部可見的,以保持整體API表面積下降。你可以很容易地把互操作的簽名改成您自己的代碼:

[DllImport("winmm.dll")] 
public static extern int mmioStringToFOURCC([MarshalAs(UnmanagedType.LPStr)] String s, int flags); 
+0

你是我心目中的英雄......覺得你很對我的幫助.... – Layan

相關問題