Windows Phone 8: dllimport not working

I am trying to import coredll and use one of its apis in a C # Windows Phone project This is a piece of code

[DllImport("coredll.dll", SetLastError = true)] static extern Int32 GetLastError(); private void Button_Click_1(object sender, RoutedEventArgs e) { try { GetLastError(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } 

I get the following exception on a Windows Phone 8 System.NotSupportedException: DllImport cannot be used by PS custom methods : this is true for any API, not just this API. Coredll is a C ++ library, and I use it in a C # project. What's going on here? Thanks, Viral

+4
source share
1 answer

What happens is that DllImport not supported on Windows Phone 8. You will need to use the Windows Runtime components (existing or those you write yourself) to switch between C ++ and .NET.

+2
source

All Articles