Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
FMOD设计器C#api崩溃_C#_Api_Pinvoke_Marshalling_Fmod - Fatal编程技术网

FMOD设计器C#api崩溃

FMOD设计器C#api崩溃,c#,api,pinvoke,marshalling,fmod,C#,Api,Pinvoke,Marshalling,Fmod,我正试图使用C#api进行FMOD Designer,并运行一个交互式音乐系统,但当我调用musicSystem.getCues(…)时,我的应用程序崩溃了 我这样称呼它: FMOD.MUSIC_ITERATOR iter = new FMOD.MUSIC_ITERATOR(); ERRCHECK(musicSystem.getCues(ref iter, musicCueName)); // Crash! if (iter.value != null) // iter.value will

我正试图使用C#api进行FMOD Designer,并运行一个交互式音乐系统,但当我调用musicSystem.getCues(…)时,我的应用程序崩溃了

我这样称呼它:

FMOD.MUSIC_ITERATOR iter = new FMOD.MUSIC_ITERATOR();
ERRCHECK(musicSystem.getCues(ref iter, musicCueName)); // Crash!

if (iter.value != null) // iter.value will be null if the cue was not found
{
    FMOD.MusicPrompt prompt = null;
    ERRCHECK(musicSystem.prepareCue((uint)iter.value.ToInt32(), ref prompt));
    musicCues.Add(prompt);
}
ERRCHECK(musicSystem.getCues(ref iter, musicCueNames[i])); // Crash!
string cueName = musicCueNames[i];
ERRCHECK(musicSystem.getCues(ref iter, cueName)); // Works!
但是我可以使用prepareCue并通过直接使用提示ID触发提示

当我检查C#包装器类时,我发现FMOD.MUSIC_迭代器通过引用直接传递给C api是可疑的,FMOD.MUSIC#迭代器中有另一个类型def,将在本机代码中填充。
这个问题也在FMOD论坛中提出,但没有得到回应。

找到了我的解决方案,我在一个包含音乐提示名称的字符串的通用列表中进行迭代,以获得提示迭代器,一个列表musicCueNames,如下所示:

FMOD.MUSIC_ITERATOR iter = new FMOD.MUSIC_ITERATOR();
ERRCHECK(musicSystem.getCues(ref iter, musicCueName)); // Crash!

if (iter.value != null) // iter.value will be null if the cue was not found
{
    FMOD.MusicPrompt prompt = null;
    ERRCHECK(musicSystem.prepareCue((uint)iter.value.ToInt32(), ref prompt));
    musicCues.Add(prompt);
}
ERRCHECK(musicSystem.getCues(ref iter, musicCueNames[i])); // Crash!
string cueName = musicCueNames[i];
ERRCHECK(musicSystem.getCues(ref iter, cueName)); // Works!
我把它改成这样:

FMOD.MUSIC_ITERATOR iter = new FMOD.MUSIC_ITERATOR();
ERRCHECK(musicSystem.getCues(ref iter, musicCueName)); // Crash!

if (iter.value != null) // iter.value will be null if the cue was not found
{
    FMOD.MusicPrompt prompt = null;
    ERRCHECK(musicSystem.prepareCue((uint)iter.value.ToInt32(), ref prompt));
    musicCues.Add(prompt);
}
ERRCHECK(musicSystem.getCues(ref iter, musicCueNames[i])); // Crash!
string cueName = musicCueNames[i];
ERRCHECK(musicSystem.getCues(ref iter, cueName)); // Works!
现在一切正常,但不知道确切原因