2012-09-09 23 views
4

我遇到了一個問題,我無法解決3天,而你是我的最後一個希望。[MonoTouch] [Bass.dll]應用程序崩潰「正在嘗試JIT編譯方法..運行時使用-aot-only」

我的目標是錄製聲音Bass.dll(有一個爲iPhone和庫的特殊版本的.NET包裝它的版本,可以在這裏找到:un4seen.com)

模擬器程序工作 (或似乎正常工作)。但是,當我試圖在iPhone上運行它 - 我得到這個錯誤:

「嘗試JIT編譯方法」(包裝本機到託管)RecordingAudioHelloWorld.Player:recordingHandler(int,intptr,int,intptr)'同時以--aot-only運行。「

錯誤發生在這裏:

RECORDPROC _recordingHandler = new RECORDPROC(recordingHandler); 

_record = Bass.BASS_RecordStart(16000, 1, BASSFlag.BASS_SPEAKER_RIGHT, _recordingHandler, IntPtr.Zero); // <-- ERROR!!! 

private int recordingHandler (int handle, IntPtr buffer, int length, IntPtr user) 
{ 
//.... 
} 

當我讀到這裏,就這樣,我改變了鏈接的行爲「鏈接SDK組件只」,但它沒有任何效果。

我可以用它做什麼嗎?

回答

5

嘗試將MonoPInvokeCallback屬性添加到您的recordingHandler函數中。請注意,您還需要將該功能設爲靜態。 YourDelegateType應該是您在C#中定義的委託類型,與此方法的簽名相對應。

[MonoPInvokeCallback (typeof(YourDelegateType)] 
private static int recordingHandler (int handle, IntPtr buffer, int length, IntPtr user) 
{ 
// ... 
} 
+1

謝謝!完美的作品! –

+0

加入 [MonoPInvokeCallbackAttribute(typeof運算(_Ov_fopen))] [的DllImport( 「__內部」,CallingConvention = CallingConvention.Cdecl,入口點= 「ov_fopen」)] 公共靜態外部不安全INT ov_fopen([在()] [的MarshalAs後(UnmanagedType.LPStr)] string path,ref File vf); 代表: [UnmanagedFunctionPointer(CallingConvention.StdCall)] delegate int _Ov_fopen(string path,ref File file); 給我另一個錯誤 錯誤MT3001:無法AOT程序集'/XXX/obj/iPhone/Debug/build-iphone5.2-8.1.1/mtouch-cache/Build/BindingLibrary.dll'(MT3001 )'@ Rolf Bjarne Kvinge – Brijesh

相關問題