[banshee] Windows: Specify CallingConvention everywhere (bgo#751045)



commit 2c72c26effe0d8188d4bee8bda0a96bd4c9f67f4
Author: Stephan Sundermann <stephansundermann gmail com>
Date:   Sun Jun 21 18:48:55 2015 +0200

    Windows: Specify CallingConvention everywhere (bgo#751045)
    
    The default CallingConvention is WinAPI, which defaults to
    the system's convention which might either be StdCall or CDecl.
    For C libraries the CallingConvention to use is CDecl
    else strange runtime errors might occur because of stack
    corruption.
    
    Since Banshee is using C libraries only, specify the CDecl
    CallinvConvention everywhere.
    
    On Windows the MDA in Visual Studio would detect a wrong
    calling convention (mono has no such detection).
    
    (We take this opportunity to use const names for libraries
    in some DllImport calls which point to the same lib.)
    
    Signed-off-by: Andrés G. Aragoneses <knocte gmail com>

 .../Banshee.GStreamer/AudioCdRipper.cs             |   14 +-
 .../Banshee.GStreamer/BpmDetector.cs               |   14 +-
 .../Banshee.GStreamer/PlayerEngine.cs              |  124 ++++++++++----------
 .../Banshee.GStreamer/Banshee.GStreamer/Service.cs |    4 +-
 .../Banshee.GStreamer/Banshee.GStreamer/TagList.cs |    8 +-
 .../Banshee.GStreamer/Transcoder.cs                |   16 ++--
 .../Banshee.GStreamerSharp/VideoManager.cs         |    8 +-
 .../Banshee.Hardware.Gio/CdromDevice.cs            |    2 +-
 .../LowLevel/CoreFoundation.cs                     |   20 ++--
 .../LowLevel/DiskArbitration.cs                    |   24 ++--
 .../Banshee.Hardware.Osx/LowLevel/IOKit.cs         |   12 +-
 .../GtkOsxApplication.cs                           |   14 +-
 .../Banshee.Unix/Banshee.IO.Unix/Directory.cs      |    2 +-
 .../GtkWindowThumbnailToolbarManager.cs            |    2 +-
 .../Windows7Support/ThumbnailToolbarManager.cs     |    8 +-
 src/Clients/Booter/Booter/Entry.cs                 |    6 +-
 .../Hyena/ConsoleCrayon.cs                         |    2 +-
 src/Core/Banshee.Core/Banshee.Base/Localization.cs |    4 +-
 src/Core/Banshee.Core/Banshee.I18n/Catalog.cs      |   14 ++-
 .../Banshee.ServiceStack/Application.cs            |    6 +-
 .../Banshee.Gui/GtkBaseClient.cs                   |    2 +-
 .../Banshee.WebBrowser/OssiferSession.cs           |   10 +-
 .../Banshee.WebBrowser/OssiferWebView.cs           |   34 +++---
 .../JavaScriptCore/JSClassDefinition.cs            |    2 +-
 .../Banshee.WebBrowser/JavaScriptCore/JSContext.cs |    8 +-
 .../Banshee.WebBrowser/JavaScriptCore/JSError.cs   |    2 +-
 .../JavaScriptCore/JSFunction.cs                   |    2 +-
 .../Banshee.WebBrowser/JavaScriptCore/JSObject.cs  |   20 ++--
 .../JavaScriptCore/JSPropertyNameAccumulator.cs    |    2 +-
 .../JavaScriptCore/JSPropertyNameArray.cs          |    8 +-
 .../Banshee.WebBrowser/JavaScriptCore/JSString.cs  |   12 +-
 .../Banshee.WebBrowser/JavaScriptCore/JSValue.cs   |   48 ++++----
 src/Libraries/Mtp/Mtp/Album.cs                     |   12 +-
 src/Libraries/Mtp/Mtp/File.cs                      |   20 ++--
 src/Libraries/Mtp/Mtp/FileSampleData.cs            |    6 +-
 src/Libraries/Mtp/Mtp/Folder.cs                    |   10 +-
 src/Libraries/Mtp/Mtp/MtpDevice.cs                 |   78 +++++++------
 src/Libraries/Mtp/Mtp/Playlist.cs                  |    8 +-
 src/Libraries/Mtp/Mtp/Track.cs                     |   18 ++--
 .../MusicBrainz/MusicBrainz/DiscFreeBsd.cs         |    8 +-
 src/Libraries/MusicBrainz/MusicBrainz/DiscLinux.cs |   10 +-
 src/Libraries/MusicBrainz/MusicBrainz/DiscWin32.cs |    6 +-
 42 files changed, 324 insertions(+), 306 deletions(-)
---
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/AudioCdRipper.cs 
b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/AudioCdRipper.cs
index 1dddc36..0041d1f 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/AudioCdRipper.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/AudioCdRipper.cs
@@ -228,26 +228,26 @@ namespace Banshee.GStreamer
         private delegate void RipperFinishedHandler (IntPtr ripper);
         private delegate void RipperErrorHandler (IntPtr ripper, IntPtr error, IntPtr debug);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr br_new (string device, int paranoia_mode, string encoder_pipeline);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void br_destroy (HandleRef handle);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void br_rip_track (HandleRef handle, int track_number, string output_path,
             HandleRef tag_list, out bool tagging_supported);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void br_set_progress_callback (HandleRef handle, RipperProgressHandler 
callback);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void br_set_mimetype_callback (HandleRef handle, RipperMimeTypeHandler 
callback);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void br_set_finished_callback (HandleRef handle, RipperFinishedHandler 
callback);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void br_set_error_callback (HandleRef handle, RipperErrorHandler callback);
     }
 }
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/BpmDetector.cs 
b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/BpmDetector.cs
index 48e497b..28e289a 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/BpmDetector.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/BpmDetector.cs
@@ -168,25 +168,25 @@ namespace Banshee.GStreamer
         private delegate void BpmDetectorFinishedHandler ();
         //private delegate void BpmDetectorErrorHandler (IntPtr error, IntPtr debug);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr bbd_new ();
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bbd_destroy (HandleRef handle);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bbd_get_is_detecting (HandleRef handle);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bbd_process_file (HandleRef handle, IntPtr path);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bbd_set_progress_callback (HandleRef handle, BpmDetectorProgressHandler 
callback);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bbd_set_finished_callback (HandleRef handle, BpmDetectorFinishedHandler 
callback);
 
-        //[DllImport ("libbanshee.dll")]
+        //[DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern void bbd_set_error_callback (HandleRef handle, BpmDetectorErrorHandler 
callback);
     }
 }
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs 
b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
index d5cac74..32cda96 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
@@ -80,6 +80,8 @@ namespace Banshee.GStreamer
     public class PlayerEngine : Banshee.MediaEngine.PlayerEngine,
         IEqualizer, IVisualizationDataSource, ISupportClutter
     {
+        internal const string LibBansheeLibrary = "libbanshee.dll";
+
         private uint GST_CORE_ERROR = 0;
         private uint GST_LIBRARY_ERROR = 0;
         private uint GST_RESOURCE_ERROR = 0;
@@ -927,198 +929,198 @@ namespace Banshee.GStreamer
 
 #endregion
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr bp_new ();
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_initialize_pipeline (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_destroy (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_eos_callback (HandleRef player, BansheePlayerEosCallback cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_error_callback (HandleRef player, BansheePlayerErrorCallback cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_vis_data_callback (HandleRef player, BansheePlayerVisDataCallback 
cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_state_changed_callback (HandleRef player,
             BansheePlayerStateChangedCallback cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_buffering_callback (HandleRef player,
             BansheePlayerBufferingCallback cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_video_pipeline_setup_callback (HandleRef player,
             VideoPipelineSetupHandler cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_tag_found_callback (HandleRef player,
             GstTaggerTagFoundCallback cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_video_prepare_window_callback (HandleRef player,
            VideoPrepareWindowHandler cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_next_track_starting_callback (HandleRef player,
             BansheePlayerNextTrackStartingCallback cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_about_to_finish_callback (HandleRef player,
             BansheePlayerAboutToFinishCallback cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_open (HandleRef player, IntPtr uri, bool maybeVideo);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_stop (HandleRef player, bool nullstate);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_pause (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_play (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_set_next_track (HandleRef player, IntPtr uri, bool maybeVideo);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_volume (HandleRef player, double volume);
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern double bp_get_volume (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_volume_changed_callback (HandleRef player,
             BansheePlayerVolumeChangedCallback cb);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_can_seek (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_audiosink_has_volume (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_set_position (HandleRef player, ulong time_ms, bool accurate_seek);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern ulong bp_get_position (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern ulong bp_get_duration (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_get_pipeline_elements (HandleRef player, out IntPtr playbin,
             out IntPtr audiobin, out IntPtr audiotee);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_application_gdk_window (HandleRef player, IntPtr window);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern VideoDisplayContextType bp_video_get_display_context_type (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_video_set_display_context (HandleRef player, IntPtr displayContext);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr bp_video_get_display_context (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_video_window_expose (HandleRef player, IntPtr displayContext, bool 
direct);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_video_window_realize (HandleRef player, IntPtr window);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_get_error_quarks (out uint core, out uint library,
             out uint resource, out uint stream);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_equalizer_is_supported (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_equalizer_set_preamp_level (HandleRef player, double level);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_equalizer_set_gain (HandleRef player, uint bandnum, double gain);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_equalizer_get_bandrange (HandleRef player, out int min, out int max);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern uint bp_equalizer_get_nbands (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_equalizer_get_frequencies (HandleRef player,
             [MarshalAs (UnmanagedType.LPArray)] out double [] freq);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_replaygain_set_enabled (HandleRef player, bool enabled);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_replaygain_get_enabled (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr clutter_gst_video_sink_new (IntPtr texture);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int bp_get_subtitle_count (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_subtitle (HandleRef player, int index);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_set_subtitle_uri (HandleRef player, IntPtr uri);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr bp_get_subtitle_uri (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr bp_get_subtitle_description (HandleRef player, int index);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern string gstreamer_version_string ();
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool bp_dvd_is_menu (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_mouse_move_notify (HandleRef player, double x, double y);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_mouse_button_pressed_notify (HandleRef player, int button, double 
x, double y);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_mouse_button_released_notify (HandleRef player, int button, double 
x, double y);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_left_notify (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_right_notify (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_up_notify (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_down_notify (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_activate_notify (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_go_to_menu (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_go_to_next_chapter (HandleRef player);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bp_dvd_go_to_previous_chapter (HandleRef player);
    }
 }
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/Service.cs 
b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/Service.cs
index ef07155..0d40458 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/Service.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/Service.cs
@@ -49,7 +49,7 @@ namespace Banshee.GStreamer
         {
         }
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void gstreamer_initialize (bool debugging, BansheeLogHandler log_handler);
 
         void IExtensionService.Initialize ()
@@ -118,7 +118,7 @@ namespace Banshee.GStreamer
             args.ProfileAvailable = available;
         }
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool gstreamer_test_pipeline (IntPtr pipeline);
 
         internal static bool TestPipeline (string pipeline)
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/TagList.cs 
b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/TagList.cs
index 6757234..1b3637e 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/TagList.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/TagList.cs
@@ -119,16 +119,16 @@ namespace Banshee.GStreamer
             get { return handle; }
         }
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr bt_tag_list_new ();
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bt_tag_list_free (HandleRef tag_list);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bt_tag_list_add_value (HandleRef tag_list, string tag_name, ref 
GLib.Value value);
 
-        [DllImport ("libbanshee.dll")]
+        [DllImport (PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void bt_tag_list_add_date (HandleRef tag_list, int year, int month, int day);
     }
 }
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/Transcoder.cs 
b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/Transcoder.cs
index 792cf39..0634e50 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/Transcoder.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/Transcoder.cs
@@ -171,32 +171,32 @@ namespace Banshee.GStreamer
         private delegate void GstTranscoderFinishedCallback(IntPtr transcoder);
         private delegate void GstTranscoderErrorCallback(IntPtr transcoder, IntPtr error, IntPtr debug);
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr gst_transcoder_new();
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void gst_transcoder_free(HandleRef handle);
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void gst_transcoder_transcode(HandleRef handle, IntPtr input_uri,
             IntPtr output_uri, string encoder_pipeline);
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void gst_transcoder_cancel(HandleRef handle);
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void gst_transcoder_set_progress_callback(HandleRef handle,
             GstTranscoderProgressCallback cb);
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void gst_transcoder_set_finished_callback(HandleRef handle,
             GstTranscoderFinishedCallback cb);
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void gst_transcoder_set_error_callback(HandleRef handle,
             GstTranscoderErrorCallback cb);
 
-        [DllImport("libbanshee.dll")]
+        [DllImport(PlayerEngine.LibBansheeLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool gst_transcoder_get_is_transcoding(HandleRef handle);
     }
 }
diff --git a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs 
b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
index 53b21b4..3667e13 100644
--- a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
+++ b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
@@ -318,13 +318,15 @@ namespace Banshee.GStreamerSharp
             }
         }
 
-        [DllImport ("libgdk-3-0.dll")]
+        private const string LibGdkLibrary = "libgdk-3-0.dll";
+
+        [DllImport (LibGdkLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr gdk_quartz_window_get_nsview (IntPtr drawable);
 
-        [DllImport ("libgdk-3-0.dll")]
+        [DllImport (LibGdkLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr gdk_x11_window_get_xid (IntPtr drawable);
 
-        [DllImport ("libgdk-3-0.dll")]
+        [DllImport (LibGdkLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr gdk_win32_drawable_get_handle (IntPtr drawable);
 
         public VideoDisplayContextType VideoDisplayContextType {
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/CdromDevice.cs 
b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/CdromDevice.cs
index ea10ff8..fb83a73 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/CdromDevice.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/CdromDevice.cs
@@ -58,7 +58,7 @@ namespace Banshee.Hardware.Gio
         }
 
         // This was literally copied and pasted from Hal's CdromDevice class.
-        [DllImport ("libc")]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl)]
         private static extern int ioctl (int device, IoctlOperation request, bool lockdoor);
 
         private enum IoctlOperation {
diff --git a/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/CoreFoundation.cs 
b/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/CoreFoundation.cs
index 6c048ca..23157c5 100644
--- a/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/CoreFoundation.cs
+++ b/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/CoreFoundation.cs
@@ -41,34 +41,34 @@ namespace Banshee.Hardware.Osx.LowLevel
     // Missing pieces that are not present in MonoMac.CoreFoundation
     internal class CoreFoundation
     {
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr CFAllocatorGetDefault ();
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr CFRunLoopGetCurrent ();
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr CFRunLoopCopyCurrentMode (IntPtr runloop);
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void CFRunLoopRun ();
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void CFRunLoopStop (IntPtr runloop);
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr CFURLCopyFileSystemPath (IntPtr url, uint style);
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void CFRelease (IntPtr ptr);
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern bool CFNumberGetValue (IntPtr number, int numberType, out Int32 val);
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void CFShow (IntPtr obj);
 
-        [DllImport (MonoMac.Constants.CoreFoundationLibrary)]
+        [DllImport (MonoMac.Constants.CoreFoundationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr CFStringCreateWithCString (IntPtr number, string str, int encoding);
     }
 }
diff --git a/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/DiskArbitration.cs 
b/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/DiskArbitration.cs
index 1df7549..5c5166f 100644
--- a/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/DiskArbitration.cs
+++ b/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/DiskArbitration.cs
@@ -33,40 +33,40 @@ namespace Banshee.Hardware.Osx.LowLevel
     {
         private const string DiskArbitrationLibrary = 
"/Systems/Library/Frameworks/DiskArbitration.framework/DiskArbitration";
 
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DASessionCreate (IntPtr allocator);
     
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DARegisterDiskAppearedCallback (IntPtr session, IntPtr match, IntPtr 
callback, IntPtr context);
     
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DARegisterDiskDescriptionChangedCallback (IntPtr session, IntPtr match, 
IntPtr watch, IntPtr callback, IntPtr context);
     
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DARegisterDiskDisappearedCallback (IntPtr session, IntPtr match, IntPtr 
callback, IntPtr context);
         
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DAUnregisterCallback (IntPtr session, IntPtr callback, IntPtr context);
 
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DASessionScheduleWithRunLoop (IntPtr session , IntPtr runLoop , IntPtr 
runloopMode);
     
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DASessionUnscheduleFromRunLoop (IntPtr session , IntPtr runLoop , IntPtr 
runloopMode);
 
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DADiskCopyDescription (IntPtr disk);
 
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DADiskCopyIOMedia (IntPtr disk);
 
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void DADiskUnmount (IntPtr disk, int unmountOptions, UnmountCallback callback, 
IntPtr context);
 
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DADiskCreateFromBSDName (IntPtr allocator, IntPtr da_session_ref, string 
name);
 
-        [DllImport (DiskArbitrationLibrary)]
+        [DllImport (DiskArbitrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr DADiskCreateFromVolumePath (IntPtr allocator, IntPtr da_session_ref, 
IntPtr urlref);
 
         public delegate void UnmountCallback (IntPtr disk, IntPtr dissenter, IntPtr context);
diff --git a/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/IOKit.cs 
b/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/IOKit.cs
index 2584a15..57da127 100644
--- a/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/IOKit.cs
+++ b/src/Backends/Banshee.Osx/Banshee.Hardware.Osx/LowLevel/IOKit.cs
@@ -86,22 +86,22 @@ namespace Banshee.Hardware.Osx.LowLevel
             return ptr;
         }
 
-        [DllImport (IOKitLibrary)]
+        [DllImport (IOKitLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void IOObjectRelease (IntPtr obj);
 
-        [DllImport (IOKitLibrary)]
+        [DllImport (IOKitLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr IORegistryEntryCreateCFProperty (IntPtr entry, IntPtr key, IntPtr 
allocator, uint options);
 
-        [DllImport (IOKitLibrary)]
+        [DllImport (IOKitLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void IORegistryEntryGetParentIterator (IntPtr iterator, IntPtr plane, out 
IntPtr parent);
 
-        [DllImport (IOKitLibrary)]
+        [DllImport (IOKitLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void IORegistryEntryGetParentEntry (IntPtr entry, string plane, out IntPtr 
parent);
 
-        [DllImport (IOKitLibrary)]
+        [DllImport (IOKitLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr IORegistryEntryFromPath (IntPtr master_port, string path);
 
-        [DllImport (IOKitLibrary)]
+        [DllImport (IOKitLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr IORegistryEntryGetPath (IntPtr entry, string plane, string path);
     }
 }
diff --git a/src/Backends/Banshee.Osx/OsxIntegration.GtkOsxApplication/GtkOsxApplication.cs 
b/src/Backends/Banshee.Osx/OsxIntegration.GtkOsxApplication/GtkOsxApplication.cs
index 0d5efa8..a0adce6 100644
--- a/src/Backends/Banshee.Osx/OsxIntegration.GtkOsxApplication/GtkOsxApplication.cs
+++ b/src/Backends/Banshee.Osx/OsxIntegration.GtkOsxApplication/GtkOsxApplication.cs
@@ -77,25 +77,25 @@ namespace OsxIntegration.GtkOsxApplication
 
         private const string GtkMacIntegrationLibrary = "libgtkmacintegration-gtk3.dylib";
 
-        [DllImport (GtkMacIntegrationLibrary)]
+        [DllImport (GtkMacIntegrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         protected extern static IntPtr gtkosx_application_get_type ();
 
-        [DllImport (GtkMacIntegrationLibrary)]
+        [DllImport (GtkMacIntegrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         protected extern static void gtkosx_application_ready (IntPtr app);
 
-        [DllImport (GtkMacIntegrationLibrary)]
+        [DllImport (GtkMacIntegrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         protected extern static void gtkosx_application_set_menu_bar (IntPtr app, IntPtr menu_shell);
 
-        [DllImport (GtkMacIntegrationLibrary)]
+        [DllImport (GtkMacIntegrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         protected extern static void gtkosx_application_insert_app_menu_item (IntPtr app, IntPtr menu_item, 
int index);
 
-        [DllImport (GtkMacIntegrationLibrary)]
+        [DllImport (GtkMacIntegrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         protected extern static void gtkosx_application_sync_menubar (IntPtr app);
 
-        [DllImport (GtkMacIntegrationLibrary)]
+        [DllImport (GtkMacIntegrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         protected extern static void gtkosx_application_set_dock_menu  (IntPtr app, IntPtr menu_shell);
 
-        [DllImport (GtkMacIntegrationLibrary)]
+        [DllImport (GtkMacIntegrationLibrary, CallingConvention = CallingConvention.Cdecl)]
         protected extern static void gtkosx_application_set_window_menu (IntPtr app, IntPtr menu_item);
 
         // TODO add more functions from GtkOsxApplication
diff --git a/src/Backends/Banshee.Unix/Banshee.IO.Unix/Directory.cs 
b/src/Backends/Banshee.Unix/Banshee.IO.Unix/Directory.cs
index 7bb7333..ec41d7e 100644
--- a/src/Backends/Banshee.Unix/Banshee.IO.Unix/Directory.cs
+++ b/src/Backends/Banshee.Unix/Banshee.IO.Unix/Directory.cs
@@ -38,7 +38,7 @@ namespace Banshee.IO.Unix
 {
     public class Directory : IDirectory
     {
-        [System.Runtime.InteropServices.DllImport ("libglib-2.0-0.dll")]
+        [System.Runtime.InteropServices.DllImport ("libglib-2.0-0.dll", CallingConvention = 
System.Runtime.InteropServices.CallingConvention.Cdecl)]
         private static extern int g_mkdir_with_parents (IntPtr path, int mode);
 
         public void Create (string directory)
diff --git a/src/Backends/Banshee.Windows/Banshee.Windows/GtkWindowThumbnailToolbarManager.cs 
b/src/Backends/Banshee.Windows/Banshee.Windows/GtkWindowThumbnailToolbarManager.cs
index 4293d0b..14fc564 100644
--- a/src/Backends/Banshee.Windows/Banshee.Windows/GtkWindowThumbnailToolbarManager.cs
+++ b/src/Backends/Banshee.Windows/Banshee.Windows/GtkWindowThumbnailToolbarManager.cs
@@ -69,7 +69,7 @@ namespace Banshee.Windows
             ThumbnailToolbarManager.Register (gdk_win32_drawable_get_handle (window.Window.Handle), cb);
         }
 
-        [DllImport ("libgdk-win32-2.0-0.dll")]
+        [DllImport ("libgdk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
         static extern IntPtr gdk_win32_drawable_get_handle (IntPtr drawable);
     }
 }
diff --git a/src/Backends/Banshee.Windows/Windows7Support/ThumbnailToolbarManager.cs 
b/src/Backends/Banshee.Windows/Windows7Support/ThumbnailToolbarManager.cs
index 2ee5c46..6ad3d57 100644
--- a/src/Backends/Banshee.Windows/Windows7Support/ThumbnailToolbarManager.cs
+++ b/src/Backends/Banshee.Windows/Windows7Support/ThumbnailToolbarManager.cs
@@ -111,13 +111,15 @@ namespace Windows7Support
 
         private delegate IntPtr Win32WinProc (IntPtr hWnd, int Msg, int wParam, int lParam);
 
-        [DllImport ("user32.dll")]
+        internal const string User32Library = "user32.dll";
+
+        [DllImport (User32Library, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr SetWindowLongW (IntPtr hWnd, int nIndex, IntPtr dwNewLong);
 
-        [DllImport ("user32.dll")]
+        [DllImport (User32Library, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr CallWindowProcW (IntPtr proc, IntPtr hWnd, int Msg, int wParam, int 
lParam);
 
-        [DllImport ("user32.dll")]
+        [DllImport (User32Library, CallingConvention = CallingConvention.Cdecl)]
         private static extern uint RegisterWindowMessage (string lpProcName);
 
         #endregion
diff --git a/src/Clients/Booter/Booter/Entry.cs b/src/Clients/Booter/Booter/Entry.cs
index 4c5738e..41fb285 100644
--- a/src/Clients/Booter/Booter/Entry.cs
+++ b/src/Clients/Booter/Booter/Entry.cs
@@ -109,10 +109,12 @@ namespace Booter
                 Assembly.GetEntryAssembly ().Location), String.Format ("{0}.exe", clientName)));
         }
 
-        [DllImport ("libgdk-win32-2.0-0.dll")]
+        private const string LibGdkLibrary = "libgdk-win32-2.0-0.dll";
+
+        [DllImport (LibGdkLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool gdk_init_check (IntPtr argc, IntPtr argv);
 
-        [DllImport ("libgdk-win32-2.0-0.dll")]
+        [DllImport (LibGdkLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void gdk_notify_startup_complete ();
 
         private static void NotifyStartupComplete ()
diff --git a/src/Core/Banshee.CollectionIndexer/Hyena/ConsoleCrayon.cs 
b/src/Core/Banshee.CollectionIndexer/Hyena/ConsoleCrayon.cs
index 453d3a0..e6de2e4 100644
--- a/src/Core/Banshee.CollectionIndexer/Hyena/ConsoleCrayon.cs
+++ b/src/Core/Banshee.CollectionIndexer/Hyena/ConsoleCrayon.cs
@@ -143,7 +143,7 @@ namespace Hyena
             }
         }
 
-        [System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty")]
+        [System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty", CallingConvention = 
System.Runtime.InteropServices.CallingConvention.Cdecl)]
         private extern static int _isatty (int fd);
 
         private static bool isatty (int fd)
diff --git a/src/Core/Banshee.Core/Banshee.Base/Localization.cs 
b/src/Core/Banshee.Core/Banshee.Base/Localization.cs
index 8036d6d..af397f7 100644
--- a/src/Core/Banshee.Core/Banshee.Base/Localization.cs
+++ b/src/Core/Banshee.Core/Banshee.Base/Localization.cs
@@ -36,6 +36,8 @@ namespace Banshee.Base
 {
     public static class Localization
     {
+        private const string LibGlibLibrary = "libglib-2.0-0.dll";
+
         private static string [] default_languages = { "C" };
         private static string [] instance_languages = null;
         private static string [] instance_xml_languages = null;
@@ -140,7 +142,7 @@ namespace Banshee.Base
             return result;
         }
 
-        [DllImport("libglib-2.0-0.dll")]
+        [DllImport (LibGlibLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr g_get_language_names();
 
         private static string [] GetLanguageNames()
diff --git a/src/Core/Banshee.Core/Banshee.I18n/Catalog.cs b/src/Core/Banshee.Core/Banshee.I18n/Catalog.cs
index b4b815b..ee9450d 100644
--- a/src/Core/Banshee.Core/Banshee.I18n/Catalog.cs
+++ b/src/Core/Banshee.Core/Banshee.I18n/Catalog.cs
@@ -179,22 +179,24 @@ namespace Banshee.I18n
             }
         }
 
-        [DllImport ("intl")]
+        private const string LibIntlibrary = "intl";
+
+        [DllImport (LibIntlibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr bind_textdomain_codeset (IntPtr domain, IntPtr codeset);
 
-        [DllImport ("intl")]
+        [DllImport (LibIntlibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr bindtextdomain (IntPtr domain, IntPtr locale_dir);
 
-        [DllImport ("intl")]
+        [DllImport (LibIntlibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr dgettext (IntPtr domain, IntPtr msgid);
 
-        [DllImport ("intl")]
+        [DllImport (LibIntlibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr dngettext (IntPtr domain, IntPtr msgid_singular, IntPtr msgid_plural, 
Int32 n);
 
-        [DllImport ("intl")]
+        [DllImport (LibIntlibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr gettext (IntPtr msgid);
 
-        [DllImport ("intl")]
+        [DllImport (LibIntlibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr ngettext (IntPtr msgid_singular, IntPtr msgid_plural, Int32 n);
     }
 }
diff --git a/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs 
b/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
index 74542a1..47a6225 100644
--- a/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
+++ b/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
@@ -54,6 +54,8 @@ namespace Banshee.ServiceStack
 
     public static class Application
     {
+        private const string LibGlibLibrary = "libglib-2.0-0.dll";
+
         public static event ShutdownRequestHandler ShutdownRequested;
         public static event Action<Client> ClientAdded;
 
@@ -81,7 +83,7 @@ namespace Banshee.ServiceStack
         }
 
 #if WIN32
-        [DllImport("msvcrt.dll") /* willfully unmapped */]
+        [DllImport ("msvcrt.dll", CallingConvention = CallingConvention.Cdecl) /* willfully unmapped */]
         public static extern int _putenv (string varName);
 #endif
 
@@ -176,7 +178,7 @@ namespace Banshee.ServiceStack
             }
         }
 
-        [DllImport ("libglib-2.0-0.dll")]
+        [DllImport (LibGlibLibrary, CallingConvention = CallingConvention.Cdecl)]
         static extern IntPtr g_get_language_names ();
 
         public static void DisplayHelp (string page)
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs 
b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
index 2f9d770..55069ec 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
@@ -97,7 +97,7 @@ namespace Banshee.Gui
         {
         }
 
-        [DllImport ("libdbus-glib-1-2.dll")]
+        [DllImport ("libdbus-glib-1-2.dll", CallingConvention = CallingConvention.Cdecl)]
         internal static extern void dbus_g_thread_init ();
 
         protected virtual void InitializeGtk ()
diff --git a/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/OssiferSession.cs 
b/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/OssiferSession.cs
index 1a084ba..eba365f 100644
--- a/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/OssiferSession.cs
+++ b/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/OssiferSession.cs
@@ -39,7 +39,7 @@ namespace Banshee.WebBrowser
         private static IntPtr handle;
         private static CookieJarChangedCallback cookie_jar_changed_callback;
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr ossifer_session_initialize (IntPtr cookie_db_path,
             CookieJarChangedCallback cookie_jar_changed_callback);
 
@@ -62,7 +62,7 @@ namespace Banshee.WebBrowser
             }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_session_set_cookie (IntPtr name, IntPtr value,
             IntPtr domain, IntPtr path, int max_age);
 
@@ -103,10 +103,10 @@ namespace Banshee.WebBrowser
             }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr ossifer_session_get_cookie (IntPtr name, IntPtr domain, IntPtr path);
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_cookie_free (IntPtr cookie);
 
         public static OssiferCookie GetCookie (string name, string domain, string path)
@@ -133,7 +133,7 @@ namespace Banshee.WebBrowser
             }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool ossifer_session_delete_cookie (IntPtr name, IntPtr domain, IntPtr path);
 
         public static bool DeleteCookie (string name, string domain, string path)
diff --git a/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/OssiferWebView.cs 
b/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/OssiferWebView.cs
index e6fe800..bf58023 100644
--- a/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/OssiferWebView.cs
+++ b/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/OssiferWebView.cs
@@ -56,7 +56,7 @@ namespace Banshee.WebBrowser
         public event EventHandler LoadStatusChanged;
         public event Action<float> ZoomChanged;
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr ossifer_web_view_get_type ();
 
         public static new GLib.GType GType {
@@ -67,7 +67,7 @@ namespace Banshee.WebBrowser
         {
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_web_view_set_callbacks (IntPtr ossifer, Callbacks callbacks);
 
         public OssiferWebView ()
@@ -168,7 +168,7 @@ namespace Banshee.WebBrowser
 
 #region Public Instance API
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr ossifer_web_view_load_uri (IntPtr ossifer, IntPtr uri);
 
         public void LoadUri (string uri)
@@ -182,7 +182,7 @@ namespace Banshee.WebBrowser
             }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_web_view_load_string (IntPtr ossifer,
             IntPtr content, IntPtr mimetype, IntPtr encoding, IntPtr base_uri);
 
@@ -207,21 +207,21 @@ namespace Banshee.WebBrowser
             }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool ossifer_web_view_can_go_forward (IntPtr ossifer);
 
         public virtual bool CanGoForward {
             get { return ossifer_web_view_can_go_forward (Handle); }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool ossifer_web_view_can_go_back (IntPtr ossifer);
 
         public virtual bool CanGoBack {
             get { return ossifer_web_view_can_go_back (Handle); }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_web_view_go_forward (IntPtr ossifer);
 
         public virtual void GoForward ()
@@ -229,7 +229,7 @@ namespace Banshee.WebBrowser
             ossifer_web_view_go_forward (Handle);
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_web_view_go_back (IntPtr ossifer);
 
         public virtual void GoBack ()
@@ -237,10 +237,10 @@ namespace Banshee.WebBrowser
             ossifer_web_view_go_back (Handle);
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_web_view_set_zoom (IntPtr ossifer, float zoomLevel);
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern float ossifer_web_view_get_zoom (IntPtr ossifer);
 
         public float Zoom {
@@ -254,10 +254,10 @@ namespace Banshee.WebBrowser
             }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_web_view_reload (IntPtr ossifer);
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_web_view_reload_bypass_cache (IntPtr ossifer);
 
         public virtual void Reload (bool bypassCache)
@@ -274,7 +274,7 @@ namespace Banshee.WebBrowser
             Reload (false);
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern void ossifer_web_view_execute_script (IntPtr ossifer, IntPtr script);
 
         public void ExecuteScript (string script)
@@ -287,28 +287,28 @@ namespace Banshee.WebBrowser
             }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr ossifer_web_view_get_uri (IntPtr ossifer);
 
         public virtual string Uri {
             get { return GLib.Marshaller.Utf8PtrToString (ossifer_web_view_get_uri (Handle)); }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr ossifer_web_view_get_title (IntPtr ossifer);
 
         public virtual string Title {
             get { return GLib.Marshaller.Utf8PtrToString (ossifer_web_view_get_title (Handle)); }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern OssiferLoadStatus ossifer_web_view_get_load_status (IntPtr ossifer);
 
         public virtual OssiferLoadStatus LoadStatus {
             get { return ossifer_web_view_get_load_status (Handle); }
         }
 
-        [DllImport (LIBOSSIFER)]
+        [DllImport (LIBOSSIFER, CallingConvention = CallingConvention.Cdecl)]
         private static extern OssiferSecurityLevel ossifer_web_view_get_security_level (IntPtr ossifer);
 
         public virtual OssiferSecurityLevel SecurityLevel {
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSClassDefinition.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSClassDefinition.cs
index 715db57..ed85c42 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSClassDefinition.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSClassDefinition.cs
@@ -154,7 +154,7 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSClassCreate (ref JSClassDefinition.JSClassDefinitionNative 
definition);
 
         private JSClass class_handle;
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSContext.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSContext.cs
index c23f74b..8a964c7 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSContext.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSContext.cs
@@ -40,7 +40,7 @@ namespace JavaScriptCore
             Raw = raw;
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSGlobalContextCreate (IntPtr globalObjectClass);
 
         public JSContext ()
@@ -53,7 +53,7 @@ namespace JavaScriptCore
             Raw = JSGlobalContextCreate (globalObjectClass.Raw);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSEvaluateScript (IntPtr ctx, JSString script,
             IntPtr thisObject, JSString sourceURL, int startingLineNumber, ref IntPtr exception);
 
@@ -91,7 +91,7 @@ namespace JavaScriptCore
             return EvaluateScript (script, null, null, 0);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern void JSGarbageCollect (IntPtr ctx);
 
         public void GarbageCollect ()
@@ -99,7 +99,7 @@ namespace JavaScriptCore
             JSGarbageCollect (Raw);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSContextGetGlobalObject (IntPtr ctx);
 
         public JSObject GlobalObject {
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSError.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSError.cs
index 1a8d6c4..eef64ab 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSError.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSError.cs
@@ -31,7 +31,7 @@ namespace JavaScriptCore
 {
     public class JSError : JSObject
     {
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSObjectMakeError (IntPtr ctx,
             IntPtr argumentCount, IntPtr args, ref IntPtr exception);
 
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSFunction.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSFunction.cs
index a6e0c37..7df736c 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSFunction.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSFunction.cs
@@ -33,7 +33,7 @@ namespace JavaScriptCore
 
     public class JSFunction : JSObject
     {
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSObjectMakeFunctionWithCallback (IntPtr ctx, JSString name,
             CallAsFunctionCallback callAsFunction);
 
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSObject.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSObject.cs
index 91bb0c9..990ccdc 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSObject.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSObject.cs
@@ -43,7 +43,7 @@ namespace JavaScriptCore
         {
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSObjectMake (IntPtr ctx, IntPtr jsClass, IntPtr data);
 
         public JSObject (JSContext context) :
@@ -92,7 +92,7 @@ namespace JavaScriptCore
 
 #region Property API
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSObjectHasProperty (IntPtr ctx, IntPtr obj, JSString propertyName);
 
         public bool HasProperty (string propertyName)
@@ -105,7 +105,7 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSObjectGetProperty (IntPtr ctx, IntPtr obj, JSString propertyName, ref 
IntPtr exception);
 
         public JSValue GetProperty (string propertyName)
@@ -121,7 +121,7 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern void JSObjectSetProperty (IntPtr ctx, IntPtr obj, JSString propertyName,
             IntPtr value, JSPropertyAttribute attributes, ref IntPtr exception);
 
@@ -142,7 +142,7 @@ namespace JavaScriptCore
             SetProperty (propertyName, value, JSPropertyAttribute.None);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSObjectDeleteProperty (IntPtr ctx, IntPtr obj, JSString propertyName, 
ref IntPtr exception);
 
         public bool DeleteProperty (string propertyName)
@@ -158,7 +158,7 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSObjectCopyPropertyNames (IntPtr ctx, IntPtr obj);
 
         private JSPropertyNameArray CopyPropertyNames ()
@@ -180,10 +180,10 @@ namespace JavaScriptCore
 
 #endregion
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern void JSObjectSetPrivate (IntPtr obj, IntPtr data);
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSObjectGetPrivate (IntPtr obj);
 
         public IntPtr UnmanagedPrivate {
@@ -191,14 +191,14 @@ namespace JavaScriptCore
             set { JSObjectSetPrivate (Raw, value); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSObjectIsFunction (IntPtr ctx, IntPtr obj);
 
         public bool IsFunction {
             get { return JSObjectIsFunction (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSObjectCallAsFunction (IntPtr ctx, IntPtr obj, IntPtr thisObject,
             IntPtr argumentCount, IntPtr [] arguments, ref IntPtr exception);
 
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSPropertyNameAccumulator.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSPropertyNameAccumulator.cs
index ef492fe..d456546 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSPropertyNameAccumulator.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSPropertyNameAccumulator.cs
@@ -35,7 +35,7 @@ namespace JavaScriptCore
         private IntPtr raw;
         #pragma warning restore 0169
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern void JSPropertyNameAccumulatorAddName (
             JSPropertyNameAccumulator accumulator, JSString propertyName);
 
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSPropertyNameArray.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSPropertyNameArray.cs
index 199681e..fb22ab4 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSPropertyNameArray.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSPropertyNameArray.cs
@@ -44,7 +44,7 @@ namespace JavaScriptCore
             this.raw = raw;
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSPropertyNameArrayRetain (JSPropertyNameArray array);
 
         public void Retain ()
@@ -52,7 +52,7 @@ namespace JavaScriptCore
             JSPropertyNameArrayRetain (this);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern void JSPropertyNameArrayRelease (JSPropertyNameArray array);
 
         public void Release ()
@@ -60,14 +60,14 @@ namespace JavaScriptCore
             JSPropertyNameArrayRelease (this);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSPropertyNameArrayGetCount (JSPropertyNameArray array);
 
         public int Count {
             get { return JSPropertyNameArrayGetCount (this).ToInt32 (); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSPropertyNameArrayGetNameAtIndex (JSPropertyNameArray array, IntPtr 
index);
 
         public string GetNameAtIndex (int index)
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSString.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSString.cs
index 2b97324..a07051c 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSString.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSString.cs
@@ -66,7 +66,7 @@ namespace JavaScriptCore
             return ToStringAndRelease (new JSString (raw));
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSStringCreateWithCharacters (IntPtr chars, IntPtr numChars);
 
         public static JSString New (string str)
@@ -85,7 +85,7 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern JSString JSStringRetain (JSString str);
 
         public void Retain ()
@@ -93,7 +93,7 @@ namespace JavaScriptCore
             JSStringRetain (this);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern void JSStringRelease (JSString str);
 
         public void Release ()
@@ -103,7 +103,7 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSStringIsEqual (JSString a, JSString b);
 
         public bool IsEqual (JSString str)
@@ -111,14 +111,14 @@ namespace JavaScriptCore
             return JSStringIsEqual (this, str);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSStringGetLength (JSString str);
 
         public int Length {
             get { return JSStringGetLength (this).ToInt32 (); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSStringGetCharactersPtr (JSString str);
 
         public string Value {
diff --git a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSValue.cs 
b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSValue.cs
index 5614b1c..25804da 100644
--- a/src/Core/Banshee.WebBrowser/JavaScriptCore/JSValue.cs
+++ b/src/Core/Banshee.WebBrowser/JavaScriptCore/JSValue.cs
@@ -52,13 +52,13 @@ namespace JavaScriptCore
             Context = context;
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueMakeBoolean (IntPtr ctx, bool value);
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueMakeNumber (IntPtr ctx, double value);
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueMakeString (IntPtr ctx, JSString value);
 
         public JSValue (JSContext ctx, bool value) : this (ctx, JSValueMakeBoolean (ctx.Raw, value)) { }
@@ -75,56 +75,56 @@ namespace JavaScriptCore
         public JSValue (JSContext ctx, JSString value) : this (ctx, JSValueMakeString (ctx.Raw, value)) { }
         public JSValue (JSContext ctx, string value) : this (ctx, JSValueMakeString (ctx.Raw, JSString.New 
(value))) { }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern JSType JSValueGetType (IntPtr ctx, IntPtr value);
 
         public JSType JSType {
             get { return JSValueGetType (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsUndefined (IntPtr ctx, IntPtr value);
 
         public bool IsUndefined {
             get { return JSValueIsUndefined (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsNull (IntPtr ctx, IntPtr value);
 
         public bool IsNull {
             get { return JSValueIsNull (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsBoolean (IntPtr ctx, IntPtr value);
 
         public bool IsBoolean {
             get { return JSValueIsBoolean (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsNumber (IntPtr ctx, IntPtr value);
 
         public bool IsNumber {
             get { return JSValueIsNumber (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsString (IntPtr ctx, IntPtr value);
 
         public bool IsString {
             get { return JSValueIsString (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsObject (IntPtr ctx, IntPtr value);
 
         public bool IsObject {
             get { return JSValueIsObject (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsObjectOfClass (IntPtr ctx, IntPtr value, IntPtr jsClass);
 
         public bool IsObjectOfClass (JSClass jsClass)
@@ -132,7 +132,7 @@ namespace JavaScriptCore
             return JSValueIsObjectOfClass (Context.Raw, Raw, jsClass.Raw);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsEqual (IntPtr ctx, IntPtr a, IntPtr b, ref IntPtr exception);
 
         public bool IsEqual (JSValue value)
@@ -143,7 +143,7 @@ namespace JavaScriptCore
             return result;
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsStrictEqual (IntPtr ctx, IntPtr a, IntPtr b);
 
         public bool IsStrictEqual (JSValue value)
@@ -151,7 +151,7 @@ namespace JavaScriptCore
             return JSValueIsStrictEqual (Context.Raw, Raw, value.Raw);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueIsInstanceOfConstructor (IntPtr ctx, IntPtr value,
             IntPtr constructor, ref IntPtr exception);
 
@@ -163,7 +163,7 @@ namespace JavaScriptCore
             return result;
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueMakeUndefined (IntPtr ctx);
 
         public static JSValue NewUndefined (JSContext ctx)
@@ -171,7 +171,7 @@ namespace JavaScriptCore
             return new JSValue (ctx, JSValueMakeUndefined (ctx.Raw));
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueMakeNull (IntPtr ctx);
 
         public static JSValue NewNull (JSContext ctx)
@@ -179,7 +179,7 @@ namespace JavaScriptCore
             return new JSValue (ctx, JSValueMakeNull (ctx.Raw));
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueMakeFromJSONString (IntPtr ctx, JSString str);
 
         public static JSValue FromJson (JSContext ctx, JSString json)
@@ -202,21 +202,21 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern bool JSValueToBoolean (IntPtr ctx, IntPtr value);
 
         public bool BooleanValue {
             get { return JSValueToBoolean (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern double JSValueToNumber (IntPtr ctx, IntPtr value);
 
         public double NumberValue {
             get { return JSValueToNumber (Context.Raw, Raw); }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueToStringCopy (IntPtr ctx, IntPtr value, ref IntPtr exception);
 
         public string StringValue {
@@ -228,7 +228,7 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueToObject (IntPtr ctx, IntPtr value, ref IntPtr exception);
 
         public JSObject ObjectValue {
@@ -240,7 +240,7 @@ namespace JavaScriptCore
             }
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr JSValueCreateJSONString (IntPtr ctx, IntPtr value, uint indent, ref 
IntPtr exception);
 
         public string ToJsonString (uint indent)
@@ -257,7 +257,7 @@ namespace JavaScriptCore
             return ToJsonString (2);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern void JSValueProtect (IntPtr ctx, IntPtr value);
 
         public void Protect ()
@@ -265,7 +265,7 @@ namespace JavaScriptCore
             JSValueProtect (Context.Raw, Raw);
         }
 
-        [DllImport (JSContext.NATIVE_IMPORT)]
+        [DllImport (JSContext.NATIVE_IMPORT, CallingConvention = CallingConvention.Cdecl)]
         private static extern void JSValueUnprotect (IntPtr ctx, IntPtr value);
 
         public void Unprotect ()
diff --git a/src/Libraries/Mtp/Mtp/Album.cs b/src/Libraries/Mtp/Mtp/Album.cs
index a189900..6252815 100644
--- a/src/Libraries/Mtp/Mtp/Album.cs
+++ b/src/Libraries/Mtp/Mtp/Album.cs
@@ -172,22 +172,22 @@ namespace Mtp
             }
         }
 
-        //[DllImport("libmtp.dll")]
+        //[DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //internal static extern IntPtr LIBMTP_new_album_t (); // LIBMTP_album_t*
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         static extern void LIBMTP_destroy_album_t (IntPtr album);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         static extern IntPtr LIBMTP_Get_Album_List (MtpDeviceHandle handle); // LIBMTP_album_t*
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         static extern IntPtr LIBMTP_Get_Album (MtpDeviceHandle handle, uint albumId); // LIBMTP_album_t*
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         internal static extern int LIBMTP_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         static extern int LIBMTP_Update_Album (MtpDeviceHandle handle, ref AlbumStruct album);
     }
 
diff --git a/src/Libraries/Mtp/Mtp/File.cs b/src/Libraries/Mtp/Mtp/File.cs
index 6e43420..fbb1607 100644
--- a/src/Libraries/Mtp/Mtp/File.cs
+++ b/src/Libraries/Mtp/Mtp/File.cs
@@ -34,34 +34,34 @@ namespace Mtp
 {
     public class File
     {
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_new_file_t (); // LIBMTP_file_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void LIBMTP_destroy_file_t (ref File file); // LIBMTP_file_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern string LIBMTP_Get_Filetype_Description (FileType type); // char const *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Filelisting (MtpDeviceHandle handle); // LIBMTP_file_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Filelisting_With_Callback (MtpDeviceHandle handle, 
ProgressFunction function, IntPtr data); // LIBMTP_file_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Filemetadata (MtpDeviceHandle handle, uint fileid); // 
LIBMTP_file_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Get_File_To_File (MtpDeviceHandle handle, uint fileId, string path, 
ProgressFunction function, IntPtr data);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void LIBMTP_destroy_filesampledata_t (ref FileSampleData data); // 
LIBMTP_filesampledata_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Get_Representative_Sample_Format (MtpDeviceHandle handle, FileType 
type, IntPtr data_array);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Send_Representative_Sample (MtpDeviceHandle handle, uint id, ref 
FileSampleData sample);
 
     }
diff --git a/src/Libraries/Mtp/Mtp/FileSampleData.cs b/src/Libraries/Mtp/Mtp/FileSampleData.cs
index 4d437a7..4cd4a7e 100644
--- a/src/Libraries/Mtp/Mtp/FileSampleData.cs
+++ b/src/Libraries/Mtp/Mtp/FileSampleData.cs
@@ -34,13 +34,13 @@ namespace Mtp
 {
     internal static class FileSample
     {
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern void LIBMTP_destroy_filesampledata_t (ref FileSampleData data); // 
LIBMTP_filesampledata_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern int LIBMTP_Get_Representative_Sample_Format (MtpDeviceHandle handle, FileType 
type, IntPtr data_array);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         public static extern int LIBMTP_Send_Representative_Sample (MtpDeviceHandle handle, uint id, ref 
FileSampleData sample);
     }
 
diff --git a/src/Libraries/Mtp/Mtp/Folder.cs b/src/Libraries/Mtp/Mtp/Folder.cs
index 5e70b66..7d6370c 100644
--- a/src/Libraries/Mtp/Mtp/Folder.cs
+++ b/src/Libraries/Mtp/Mtp/Folder.cs
@@ -208,19 +208,19 @@ namespace Mtp
         }
 
         // Folder Management
-        //[DllImport("libmtp.dll")]
+        //[DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern IntPtr LIBMTP_new_folder_t (); // LIBMTP_folder_t*
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void LIBMTP_destroy_folder_t (IntPtr folder);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Folder_List (MtpDeviceHandle handle); // LIBMTP_folder_t*
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Find_Folder (IntPtr folderList, uint folderId); // 
LIBMTP_folder_t*
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern uint LIBMTP_Create_Folder (MtpDeviceHandle handle, string name, uint parentId, 
uint storageId);
     }
 
diff --git a/src/Libraries/Mtp/Mtp/MtpDevice.cs b/src/Libraries/Mtp/Mtp/MtpDevice.cs
index 89267da..05aef59 100644
--- a/src/Libraries/Mtp/Mtp/MtpDevice.cs
+++ b/src/Libraries/Mtp/Mtp/MtpDevice.cs
@@ -402,76 +402,78 @@ namespace Mtp
             return s;
         }
 
+        internal const string LibMtpLibrary = "libmtp.dll";
+
         // Device Management
-        [DllImport("libmtp.dll")]
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void LIBMTP_Init ();
-            
+
         // Clears out the error stack and frees any allocated memory.
-        [DllImport("libmtp.dll")]
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void LIBMTP_Clear_Errorstack (MtpDeviceHandle handle);
-        
-        [DllImport("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         internal static extern int LIBMTP_Delete_Object (MtpDeviceHandle handle, uint object_id);
-            
+
         // Gets the first connected device:
-        //[DllImport("libmtp.dll")]
+        //[DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern IntPtr LIBMTP_Get_First_Device (); // LIBMTP_mtpdevice_t *
-        
+
         // Gets the storage information
-        [DllImportAttribute("libmtp.dll")]
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Get_Storage (MtpDeviceHandle handle, int sortMode);
-        
+
         // Formats the supplied storage device attached to the device
-        //[DllImportAttribute("libmtp.dll")]
+        //[DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern int LIBMTP_Format_Storage (MtpDeviceHandle handle, ref DeviceStorage 
storage);
-        
+
         // Counts the devices in the list
-        //[DllImportAttribute("libmtp.dll")]
+        //[DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern uint LIBMTP_Number_Devices_In_List (MtpDeviceHandle handle);
-        
-        [DllImportAttribute("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern ErrorCode LIBMTP_Get_Connected_Devices (out IntPtr list); //LIBMTP_mtpdevice_t 
**
 
-        [DllImport ("libmtp.dll")]
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern ErrorCode LIBMTP_Detect_Raw_Devices (ref IntPtr list, ref int count); 
//LIBMTP_raw_device_t
 
-        [DllImport ("libmtp.dll")]
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Open_Raw_Device (ref RawDeviceStruct rawdevice);
 
         // Deallocates the memory for the device
-        [DllImportAttribute("libmtp.dll")]
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void LIBMTP_Release_Device (IntPtr device);
 
-        //[DllImportAttribute("libmtp.dll")]
+        //[DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern int LIBMTP_Reset_Device (MtpDeviceHandle handle);
-        
-        [DllImport("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Get_Batterylevel (MtpDeviceHandle handle, out ushort maxLevel, out 
ushort currentLevel);
-        
-        [DllImportAttribute("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Modelname (MtpDeviceHandle handle); // char *
-        
-        [DllImportAttribute("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Serialnumber (MtpDeviceHandle handle); // char *
-        
-        [DllImportAttribute("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Deviceversion (MtpDeviceHandle handle); // char *
-        
-        [DllImportAttribute("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Friendlyname (MtpDeviceHandle handle); // char *
-        
-        [DllImport("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Set_Friendlyname (MtpDeviceHandle handle, string name);
-        
-        [DllImportAttribute("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Errorstack (MtpDeviceHandle handle); // LIBMTP_error_t *
-        
-        [DllImportAttribute("libmtp.dll")]
+
+        [DllImport (LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Get_Supported_Filetypes (MtpDeviceHandle handle, ref IntPtr types, 
ref ushort count); // uint16_t **const
-        
-        
+
+
         // void LIBMTP_Release_Device_List (LIBMTP_mtpdevice_t *)
-                
+
 
         // int LIBMTP_Detect_Descriptor (uint16_t *, uint16_t *);
         /*
diff --git a/src/Libraries/Mtp/Mtp/Playlist.cs b/src/Libraries/Mtp/Mtp/Playlist.cs
index 95dc4c9..3bb0a5d 100644
--- a/src/Libraries/Mtp/Mtp/Playlist.cs
+++ b/src/Libraries/Mtp/Mtp/Playlist.cs
@@ -100,16 +100,16 @@ namespace Mtp
 
         // Playlist Management
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void LIBMTP_destroy_playlist_t (IntPtr playlist);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Playlist_List (MtpDeviceHandle handle); // LIBMTP_playlist_t*
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Create_New_Playlist (MtpDeviceHandle handle, ref PlaylistStruct 
metadata);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Update_Playlist (MtpDeviceHandle handle, ref PlaylistStruct 
playlist);
     }
 
diff --git a/src/Libraries/Mtp/Mtp/Track.cs b/src/Libraries/Mtp/Mtp/Track.cs
index d3924dd..5fdcd3c 100644
--- a/src/Libraries/Mtp/Mtp/Track.cs
+++ b/src/Libraries/Mtp/Mtp/Track.cs
@@ -245,31 +245,31 @@ namespace Mtp
                 throw new LibMtpException (ErrorCode.General);
         }
         
-        //[DllImport("libmtp.dll")]
+        //[DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern IntPtr LIBMTP_new_track_t (); // LIBMTP_track_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern void LIBMTP_destroy_track_t (IntPtr track); // LIBMTP_track_t *
 
-        //[DllImport("libmtp.dll")]
+        //[DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern IntPtr LIBMTP_Get_Tracklisting (MtpDeviceHandle handle); //LIBMTP_track_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern IntPtr LIBMTP_Get_Tracklisting_With_Callback (MtpDeviceHandle handle, 
ProgressFunction callback, IntPtr data); // LIBMTP_track_t *
 
-        //[DllImport("libmtp.dll")]
+        //[DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern IntPtr LIBMTP_Get_Trackmetadata (MtpDeviceHandle handle, uint trackId); // 
LIBMTP_track_t *
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Get_Track_To_File (MtpDeviceHandle handle, uint trackId, string 
path, ProgressFunction callback, IntPtr data);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Send_Track_From_File (MtpDeviceHandle handle, string path, ref 
TrackStruct track, ProgressFunction callback, IntPtr data);
 
-        [DllImport("libmtp.dll")]
+        [DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         private static extern int LIBMTP_Update_Track_Metadata (MtpDeviceHandle handle, ref TrackStruct 
metadata);
 
-        //[DllImport("libmtp.dll")]
+        //[DllImport (MtpDevice.LibMtpLibrary, CallingConvention = CallingConvention.Cdecl)]
         //private static extern int LIBMTP_Track_Exists (MtpDeviceHandle handle, uint trackId);
 
         //int     LIBMTP_Get_Track_To_File_Descriptor (MtpDeviceHandle handle, uint trackId, int const, 
LIBMTP_progressfunc_t const, void const *const)
diff --git a/src/Libraries/MusicBrainz/MusicBrainz/DiscFreeBsd.cs 
b/src/Libraries/MusicBrainz/MusicBrainz/DiscFreeBsd.cs
index 85b094a..537c7b4 100644
--- a/src/Libraries/MusicBrainz/MusicBrainz/DiscFreeBsd.cs
+++ b/src/Libraries/MusicBrainz/MusicBrainz/DiscFreeBsd.cs
@@ -34,12 +34,12 @@ namespace MusicBrainz
         // no delay
         const int O_NONBLOCK = 0x0004;
 
-        [DllImport ("libc", CharSet = CharSet.Auto, SetLastError = true)]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto, 
SetLastError = true)]
         static extern int open (string path, int flags);
 #endregion
 
 #region <unistd.h>
-        [DllImport ("libc", SetLastError = true)]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
         static extern int close (int d);
 #endregion
 
@@ -69,7 +69,7 @@ namespace MusicBrainz
             public byte ending_track;
         }
         const ulong CDIOREADTOCHEADER = 1074029316;
-        [DllImport ("libc", EntryPoint = "ioctl")]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ioctl")]
         static extern int cd_read_toc_header (int fd, ulong request, ref ioc_toc_header data);
         static int cd_read_toc_header (int fd, ref ioc_toc_header data)
         {
@@ -84,7 +84,7 @@ namespace MusicBrainz
             public IntPtr data; // cd_toc_entry*
         }
         const ulong CDIOREADTOCENTRYS = 3222299397;
-        [DllImport ("libc", EntryPoint = "ioctl")]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ioctl")]
         static extern int cd_read_toc_entrys (int fd, ulong request, ref ioc_read_toc_entry data);
         static int cd_read_toc_entrys (int fd, ref ioc_read_toc_entry data)
         {
diff --git a/src/Libraries/MusicBrainz/MusicBrainz/DiscLinux.cs 
b/src/Libraries/MusicBrainz/MusicBrainz/DiscLinux.cs
index 2556cf6..a08d57e 100644
--- a/src/Libraries/MusicBrainz/MusicBrainz/DiscLinux.cs
+++ b/src/Libraries/MusicBrainz/MusicBrainz/DiscLinux.cs
@@ -37,27 +37,27 @@ namespace MusicBrainz
         const int CD_FRAMES = 75;
         const int XA_INTERVAL = ((60 + 90 + 2) * CD_FRAMES);
 
-        [DllImport ("libc", CharSet = CharSet.Auto)]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
         static extern int open (string path, int flags);
 
-        [DllImport ("libc")]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl)]
         static extern int close (int fd);
 
-        [DllImport ("libc", EntryPoint = "ioctl")]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ioctl")]
         static extern int read_toc_header (int fd, int request, ref cdrom_tochdr header);
         static int read_toc_header (int fd, ref cdrom_tochdr header)
         {
             return read_toc_header (fd, CDROMREADTOCHDR, ref header);
         }
 
-        [DllImport ("libc", EntryPoint = "ioctl")]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ioctl")]
         static extern int read_multisession (int fd, int request, ref cdrom_multisession multisession);
         static int read_multisession (int fd, ref cdrom_multisession multisession)
         {
             return read_multisession (fd, CDROMMULTISESSION, ref multisession);
         }
 
-        [DllImport ("libc", EntryPoint = "ioctl")]
+        [DllImport ("libc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ioctl")]
         static extern int read_toc_entry (int fd, int request, ref cdrom_tocentry entry);
         static int read_toc_entry (int fd, ref cdrom_tocentry entry)
         {
diff --git a/src/Libraries/MusicBrainz/MusicBrainz/DiscWin32.cs 
b/src/Libraries/MusicBrainz/MusicBrainz/DiscWin32.cs
index c357d40..7ea5e7d 100644
--- a/src/Libraries/MusicBrainz/MusicBrainz/DiscWin32.cs
+++ b/src/Libraries/MusicBrainz/MusicBrainz/DiscWin32.cs
@@ -29,10 +29,12 @@ namespace MusicBrainz
 {
     internal sealed class DiscWin32 : LocalDisc
     {
-        [DllImport ("winmm")]
+        private const string WinMmLibrary = "winmm";
+
+        [DllImport (WinMmLibrary, CallingConvention = CallingConvention.Cdecl)]
         static extern Int32 mciSendString ([MarshalAs(UnmanagedType.LPTStr)] String command, 
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder buffer, Int32 bufferSize, IntPtr hwndCallback);
 
-        [DllImport ("winmm")]
+        [DllImport (WinMmLibrary, CallingConvention = CallingConvention.Cdecl)]
         static extern Int32 mciGetErrorString (Int32 errorCode, [MarshalAs(UnmanagedType.LPTStr)] 
StringBuilder errorText, Int32 errorTextSize);
 
         delegate void MciCall (string result);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]