2012-12-20 36 views

回答

4

仅仅因为你可以在你的C#WP8项目添加[DllImport ...]并不意味着它的支持。

private void Button_Click_1(object sender, RoutedEventArgs e) 
    { 
     var v = GetCurrentThread(); 
    } 

    [DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] 
    public static extern IntPtr GetCurrentThread(); 

...将在WP8中给出NotSupportedException。尽管MSDN says that this is a supported Win32 API for WP8.

这也可以解释为什么你失去了使用PCL DllImport的能力...

+0

感谢保罗。你挽救了我的剩余头发。 – tofutim

+0

如果DllImport被最终的exe支持,你认为可以使用反射来调用PCL中的DllImport吗? – tofutim